提交到nexus时候报错:
Downloading: http://nexus.easypeng.lab:8082/nexus/content/repositories/snapshots/com/easypeng/framework/template/framework-template/1.0-SNAPSHOT/maven-metadata.xml
[WARNING] Could not transfer metadata com.easypeng.framework.template:framework-template:1.0-SNAPSHOT/maven-metadata.xml from/to snapshots (http://nexus.easypeng.lab:8082/nexus/content/repositories/snapshots/): Connect to nexus.easypeng.lab:8082 [nexus.easypeng.lab/127.0.0.1] failed: Connection refused: connect
端口号错误
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project framework-template: Failed to deploy artifacts: Could not transfer artifact com.easypeng.framework.template:framework-template:war:1.0-20170721.105730-3 from/to snapshots1 (http://nexus.easypeng.lab:8081/nexus/content/repositories/snapshots/): Failed to transfer file: http://nexus.easypeng.lab:8081/nexus/content/repositories/snapshots/com/easypeng/framework/template/framework-template/1.0-SNAPSHOT/framework-template-1.0-20170721.105730-3.war. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
setting.xml 和pom.xml 文件的id 不一致
原来是没有配置认证。
maven目录conf的setting.xml里,
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
用户名和密码都是nexus的。再次deploy即可。
**注意这里的id要和pom.xml里远程deploy的地址对应一致,我的pom.xml里配置:**
<!-- 配置远程发布到私服,mvn deploy -->
<distributionManagement>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>http://10.1.81.199:8081/nexu
s/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://10.1.81.199:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
如果这里不配置,会报错:
报错:Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project Git-demo: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
nexus maven setting 和pom 文件配置
最新推荐文章于 2024-05-06 09:52:12 发布