Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project maven_day02_dao: Failed to deploy artifacts: Could not transfer artifact com.itheima:maven_day02_dao:jar:1.0-20200420.150331-1 from/to Snapshots (http://localhost:8081/nexus/content/repositories/snapshots/): Failed to transfer file: http://localhost:8081/nexus/content/repositories/snapshots/com/itheima/maven_day02_dao/1.0-SNAPSHOT/maven_day02_dao-1.0-20200420.150331-1.jar. Return code is: 401, ReasonPhrase: Unauthorized.
原因:我本地maven配置的id或账号或密码 验证 不通过。 最后看了下,原来是maven Id里面的配置的 和项目里面配置的snapshotRepository的id 不一样(maven里面的原来已经存在),然后只是在项目的pom中新增而已,结果是因为“区分大小写”。
nexus 配置文件到本地maven本地仓库步骤
1、在maven的Settings.Xml 文件中的 <servers> 节点下新增
<server> <id>releases</id> <username>admin</username> <password>admin123</password> </server> <server> <id>Snapshots</id> <username>admin</username> <password>admin123</password> </server>
在项目中的pom.xml文件project 节点下(一般放在最后面,可以具体细化到每个模块)
<distributionManagement> <repository> <id>releases</id> <url>http://localhost:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <url>http://localhost:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>
id=snapshots 对应的Pom.xml中version中的编译类型,如<version>1.0-SNAPSHOT</version>
3、编译到nexus,