本地仓库
配置maven 本地仓库位置。
//示例
<localRepository>D:\develop-kit\maven_repository</localRepository>
远程镜像
配置远程仓库镜像--提高下载速度
mirrorOf标签用以拦截指定的repository仓库走镜像下载,填写值为repository id
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror><mirror>
<id>huaweicloud</id>
<mirrorOf>*</mirrorOf>
<name>huaweicloud</name>
<url>https://mirrors.huaweicloud.com/repository/maven/</url>
</mirror>
<mirror>
<id>tencent</id>
<mirrorOf>*</mirrorOf>
<name>tencent</name>
<url>http://mirrors.cloud.tencent.com/nexus/repository/maven-public/</url>
</mirror>
配置代理
<proxies>
<!-- proxy
| Specification for one proxy, to be used in connecting to the network.
| -->
<proxy>
<id>optional</id>
<active>true</active>
<protocol>http</protocol>
<!--
<username></username> //Https会需要
<password></password> //Https会需要
-->
<host>10.26.2.36</host> //代理服务器ip
<port>8981</port>
<!--
<nonProxyHosts>10.26.2.**</nonProxyHosts> //配置哪些ip不走代理
-->
</proxy>
</proxies>
远程服务器连接配置账号密码 和远程仓库配合使用
<server>
<id>deploymentRepo</id> // repository id 填写
<username>repouser</username>
<password>repopwd</password>
</server>
<repositories>
<repository>
<id>jdk14</id>
<name>Repository for JDK 1.4 builds</name>
<url>http://www.myhost.com/maven/jdk14</url>
<layout>default</layout>
<snapshotPolicy>always</snapshotPolicy>
</repository>
</repositories>
多环境配置
这个要跟pom文件里plugins结合使用达到更灵活的效果。
<profiles> <profile> <id>dev</id> <properties> <profile.id>dev</profile.id> <docker.host>http://dev.demo.com:2375</docker.host> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <profile> <id>test</id> <properties> <profile.id>test</profile.id> <docker.host>http://test.demo.com375</docker.host> </properties> </profile> <profile> <id>prod</id> <properties> <profile.id>prod</profile.id> <docker.host>http://prod.demo.com:2375</docker.host> </properties> </profile> </profiles>
<build>
<finalName>mall-order</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources/</directory>
<!-- 打包时,将对应配置文件先排除 -->
<excludes>
<exclude>**/*.yml</exclude>
</excludes>
<includes>
<!--如果有其他定义通用文件,需要包含进来-->
</includes>
</resource>
<resource>
<!-- 通过自定义的节点来激活指定的配置文件 -->
<directory>src/main/resources/${profile.active}</directory>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>dev</id>
<properties>
<!-- 自定义节点profile.active-->
<profile.active>dev</profile.active>
</properties>
<!--activation用来指定激活方式,可以根据jdk环境,环境变量,文件的存在或缺失-->
<activation>
<!-- 表示默认激活-->
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>test</id>
<properties>
<profile.active>test</profile.active>
</properties>
</profile>
</profiles>
插件管理配置
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<includes>
<include>**/OrderServiceTest.java</include>
</includes>
<excludes>
<exclude>**/OrderService2Test.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>com.mic.tech</groupId>
<artifactId>my-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<configuration>
<path>${project.basedir}</path>
</configuration>
<executions>
<execution>
<phase>compile</phase> //绑定maven对应生命周期
<goals>
<goal>sumFileCount</goal> //插件对应目标,控制台会输出
</goals>
</execution>
</executions>
</plugin>