POM功能
1.跳过测试
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skip>true</skip> </configuration> </plugin>
2.打包带依赖
<plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin>
3.编译
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> <!-- <compilerArgs><arg>-parameters</arg></compilerArgs> --> </configuration> <version>3.8.1</version> </plugin>
4.打包带源码
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>3.0.0</version> <!-- 绑定source插件到Maven的生命周期,并在生命周期后执行绑定的source的goal --> <executions> <execution> <!-- 绑定source插件到Maven的生命周期 --> <phase>compile</phase> <!--在生命周期后执行绑定的source插件的goals --> <goals> <goal>jar-no-fork</goal> </goals> </execution> </executions> </plugin>
5.统一版本
<properties> <cglib.version>3.3.0</cglib.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> <version>${cglib.version}</version> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> </dependency> </dependencies>
6. 使用上级POM
<!--上级--> <modules> <module>caMask-xtx</module> <module>caMask-mssp-utrust</module> </modules> <!--下级--> <parent> <groupId>cn.org.bjca.caMask</groupId> <artifactId>caMask</artifactId> <version>1.1.0-SNAPSHOT</version> </parent>
7.打包可执行jar
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.0.4.RELEASE</version> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> <configuration> <mainClass>cn.org.bjca.test.TestCLI</mainClass> </configuration> </plugin>