修改maven settings.xml文件

1
2
3
4
5
6
7
8
9
10
11
12
13
<servers>
<server>
<id>private-nexus-library-releases</id>
<username>username</username>
<password>password</password>
<!---nexus私服的用户名和密码 ---->
</server>
<server>
<id>private-nexus-library-snapshots</id>
<username>username</username>
<password>password</password>
</server>
</servers>

修改项目pom文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<!--发布-->
<distributionManagement>
<repository>
<id>private-nexus-library-releases</id>
<name>private-nexus-library-releases</name>
<url>http://host:port/maven-web/repositories/releases/</url>
<!--- url可以在nexus私服repositories列表看到 ---->
</repository>
<snapshotRepository>
<id>private-nexus-library-snapshots</id>
<name>private-nexus-library-snapshots</name>
<url>http://host:port/maven-web/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>

注意事项

  1. server 的 id 要与 repository 的 id 保持一致。
  2. nexus私用不能解析parent.version 中的${}表达式, 要写常量. 否则会导致deploy失败.