工作中需要写些小demo或是新建项目的时候需要新建maven项目的pom.xml配置,这就需要重新配置maven配置文件,这个时候总是会出现心里想要的配置找不到,然后需要去百度->测试->修改->百度...。感觉很浪费时间,所以这里总结下maven的常用配置,都是自己实践过的,而且长期更新。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yihengliu</groupId>
<artifactId>javacore</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>javacore Maven Webapp</name>
<url>http://maven.apache.org</url>
<!-- 使用阿里 maven 库 -->
<repositories>
<repository>
<id>ali-maven</id>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
</repository>
</repositories>
<!-- local repositories and plugin repositories settings -->
<repositories>
<repository>
<id>nexus</id>
<name>nexus</name>
<url>http://192.168.6.106:8081/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>nexus</name>
<url>http://192.168.6.106:8081/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>javacore</finalName>
<plugins>
<!-- 配置编译环境,可以带编译参数 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
<!-- 配置生成可运行jar包打包依赖jar到jar包中(打包class文件),需要修改packaging属性位jar -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>com.ncjk.dataprocess.process.ProcessErrorData</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- tomcat远程部署 -->
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<server>mytomcat7</server>
<!-- 远程tomcat,实现自动部署 -->
<url>http://192.168.6.204:8080/manager/text</url>
<username>admin</username>
<password>admin@123</password>
<path>/JK-TVMR</path>
<!-- 如果路径在tomcat服务器中已存在并且使用mvn tomcat7:deploy命令的话,上面的配置中一定要配置<update>true</update> -->
<update>true</update>
</configuration>
</plugin>
</plugins>
</build>
</project>