Maven的几个常用plugin
maven-compiler-plugin
编译Java源码,一般只需设置编译的jdk版本
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.6.0</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin>
maven-dependency-plugin
用于复制依赖的jar包到指定的文件夹里
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.10</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/lib</outputDirectory> </configuration> </execution> </executions> </plugin>
maven-jar-plugin
打成jar时,设定manifest的参数,比如指定运行的Mainclass,还有依赖的jar包,加入classpath中
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.4</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>/data/lib</classpathPrefix> <mainClass>com.zhang.spring.App</mainClass> </manifest> </archive> </configuration> </plugin>
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持毛票票!