1.设置nexus
将相关repository的Access Settings -> Deployment Policy 设置成[Allow Redeploy]
2. 设置身份验证
在maven配置文件conf/settings.xml添加身份验证信息
1 2 3 4 5 6 7
| <servers> <server> <username>admin</username> <password>admin123</password> <id>nexus-3rd</id> </server> </servers>
|
注意:这里的id必须与pom.xml中distributionManagement/repository/id保持一致。
3.设置pom.xml中
增加以下节点
1 2 3 4 5 6
| <distributionManagement> <repository> <id>nexus-3rd</id> <url>http://localhost:8081/nexus/content/repositories/thirdparty/</url> </repository> </distributionManagement>
|
4.上传源码
若要上传源码,其配置如下
1 2 3 4 5 6 7 8 9 10 11 12
| <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin>
|
5.执行编译命令
mvn deploy -Dmaven.test.skip=true
在eclipse使用时不需要添加mvn
-Dmaven.test.skip=true意为跳过单元测试,可以酌情删减
6.输出的预期结果
1 2 3
| .... Uploading: http://localhost:8081/nexus/content/repositories/thirdparty/xxx/xxx.jar Uploaded: http://localhost:8081/nexus/content/repositories/thirdparty/xxx/xxx.jar (29582 KB at 18829.7 KB/sec)
|