搭建好nexus3后,配置了~/.m2/settings.xml文件,和项目中的pom.xml文件。以下apache
<?xml version="1.0" encoding="utf-8"?> <settings> <servers> <!-- 这是公司的maven nexus 用户名密码 --> <server> <id>souban-nexus</id> <username>打码处理</username> <password>打码处理</password> </server> <!-- 这是我本身刚搭建的nexus仓库 用户密码 --> <server> <id>wooo-nexus</id> <!-- 这里的id和项目中pom配置的的id应该是同样的 --> <username>打码处理</username> <password>打码处理</password> </server> </servers> <mirrors> <mirror> <!-- aliyun 加速器 --> <id>aliyun-repository-public</id> <name>Maven Repository Manager running on aliyun</name> <url>http://maven.aliyun.com/nexus/content/groups/public</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <!-- aliyun 加速器 --> <id>aliyun-repository-central</id> <name>Maven Repository Manager running on aliyun</name> <url>http://maven.aliyun.com/nexus/content/repositories/central</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> </settings>
.... <!-- 从哪里去拉jar包 --> <repositories> <repository> <id>wooo-nexus-snapshots</id> <name>release repository</name> <url>http://打码处理/repository/release/</url> </repository> <repository> <id>wooo-nexus-release</id> <name>snapshots repository</name> <url>http://打码处理/repository/snapshots/</url> </repository> </repositories> <!-- 须要打包上传到的目的地 --> <distributionManagement> <repository> <id>wooo-nexus</id> <name>release</name> <url>http://打码处理/repository/release/</url> </repository> <snapshotRepository> <id>wooo-nexus</id> <name>snapshots</name> <url>http://打码处理/repository/snapshots/</url> </snapshotRepository> </distributionManagement> ....
新建了两个format为maven(group)的仓库,如图:maven
随后我在pom文件中作了以下配置url
<repositories> <repository> <id>wooo-nexus-snapshots</id> <name>release repository</name> <url>http://打码处理/repository/release/</url> </repository> <repository> <id>wooo-nexus-release</id> <name>snapshots repository</name> <url>http://打码处理/repository/snapshots/</url> </repository> </repositories> <distributionManagement> <repository> <id>wooo-nexus</id> <name>release</name> <url>http://手动打码/repository/release/</url> <!-- 更改了这一行--> </repository> <snapshotRepository> <id>wooo-nexus</id> <name>snapshots</name> <url>http://手动打码/repository/snapshots/</url> <!-- 还有这一行--> </snapshotRepository> </distributionManagement>
而后再使用mvn deploy命令时, 报了以下的错:code
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project tensquare_common: Failed to deploy artifacts: Could not transfer artifact io.wooo:tensquare_common:jar:0.0.4-20181116.063410-1 from/to wooo-nexus (http://手动打码/repository/snapshots/): Failed to transfer file: http://打码处理/repository/snapshots/io/wooo/tensquare_common/0.0.4-SNAPSHOT/tensquare_common-0.0.4-20181116.063410-1.jar. Return code is: 405, ReasonPhrase: PUT. -> [Help 1]
解决过程太复杂,不过赘述。直接说解决方案吧。我把配置中的url的/repository/snapshots
换为了/repository/maven-snapshots
,maven-snapshots如图: 这个是nexus自带的仓库还有一个maven-release也是。orm
按照网上的理解是,你建了一个group的仓库选择了maven-shapshots会指向该仓库,因而我就新建了上上个截图的两个仓库,而后在配置文件中配好就死活报错。 而后把配置改成了这样之后:server
<repositories> <repository> <id>wooo-nexus-snapshots</id> <name>release repository</name> <url>http://手动打码/repository/release/</url> </repository> <repository> <id>wooo-nexus-release</id> <name>snapshots repository</name> <url>http://手动打码/repository/snapshots/</url> </repository> </repositories> <distributionManagement> <repository> <id>wooo-nexus</id> <name>release</name> <url>http://手动打码/repository/maven-release/</url> <!-- 更改了这一行--> </repository> <snapshotRepository> <id>wooo-nexus</id> <name>snapshots</name> <url>http://手动打码/repository/maven-snapshots/</url> <!-- 还有这一行--> </snapshotRepository> </distributionManagement>
就没有报错了,因而我知道问题所在了。 而后我删了自带的maven-snapshots和maven-release,自建了下面两个仓库:xml
配置文件以下:utf-8
<repositories> <repository> <id>wooo-nexus-snapshots</id> <name>release repository</name> <url>http://手动打码/repository/release/</url> </repository> <repository> <id>wooo-nexus-release</id> <name>snapshots repository</name> <url>http://手动打码/repository/snapshots/</url> </repository> </repositories> <distributionManagement> <repository> <id>wooo-nexus</id> <name>release</name> <url>http://手动打码/repository/release/</url> <!-- 更改了这一行--> </repository> <snapshotRepository> <id>wooo-nexus</id> <name>snapshots</name> <url>http://手动打码/repository/snapshots/</url> <!-- 还有这一行--> </snapshotRepository> </distributionManagement>
nexus配置以下,两个仓库配置是同样的。it