注意:确保idea中项目为maven项目,并且在nexus中已经创建了maven私服。
1、配置pom.xml中推送代码配置
<distributionManagement>
<repository>
<id>releases</id>
<url>http://127.0.0.1:8001/repository/myRelease/</url>
</repository>
<snapshotRepository>
<id>Snapshots</id>
<url>http://127.0.0.1:8001/repository/mySnapshot/</url>
</snapshotRepository>
</distributionManagement>
2、配置maven中的setting.xml文件
<servers>
<server>
<id>releases</id>
<username>admin</username>
<password>nexus</password>
</server>
<server>
<id>Snapshots</id>
<username>admin</username>
<password>nexus</password>
</server>
<server>
<id>my-maven-public</id>
<username>admin</username>
<password>nexus</password>
</server>
</servers>
<profiles>
<profile>
<id>my-maven-public</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository>
<id>my-maven-public</id>
<url>http://127.0.0.1:8001/repository/maven-public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
3、执行上传(maven->lifecycle->deploy->run maven build)
成功:
4、验证
登录nexus页面查看