1、maven全局配置settings.xml
<mirrors> <!-- 阿里云仓库 --> <mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/repositories/central/</url> </mirror> <!-- 中央仓库1 一般不用 <mirror> <id>repo1</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo1.maven.org/maven2/</url> </mirror> --> <!-- 中央仓库2 默认 <mirror> <id>repo2</id> <mirrorOf>central</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://repo2.maven.org/maven2/</url> </mirror> --> <!-- nexus中的仓库 自定义的本地仓库或代理仓库 <mirror> <id>public</id> <mirrorOf>central</mirrorOf> <name>central repository</name> <url>http://192.168.1.21:8081/repository/maven-public/</url> </mirror> --> </mirrors> <profiles> <profile><!-- 定义配置文件 --> <id>myprofile</id> <repositories> <repository> <id>nexus</id> <name>nexus</name> <url>http://192.168.0.100:8888/repository/maven-central/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <name>aliplugin</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles><!-- 激活配置文件 --> <activeProfile>myprofile</activeProfile> </activeProfiles> <servers><!-- 发布时使用的用户名和密码 --> <server> <id>releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>snapshots</id> <username>admin</username> <password>admin123</password> </server> </servers>
2、项目配置文件pom.xml,配置待发布目标仓库
<distributionManagement> <repository> <id>releases</id> <name>maven-releases</name> <url>http://192.168.0.100:8888/repository/maven-releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <name>maven-snapshots</name> <url>http://192.168.0.100:8888/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement>