两个位置 项目第三方jar包位置: http://x.x.x.x:9903/nexus/content/repositories/thirdparty/ 项目deploy SNAPSHOT位置: http://x.x.x.x:9903/nexus/content/repositories/demoProject/
nexus使用配置 1, pom 文件配置(每一个项目)
<!--发布maven私服-->
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>nexus-releases</name>
<url>http://x.x.x.x:9903/nexus/content/repositories/thirdparty/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>nexus-snapshots</name>
<url>http://x.x.x.x:9903/nexus/content/repositories/demoProject/</url>
</snapshotRepository>
</distributionManagement>
2,maven setting 文件配置
2.1 server 配置
<servers>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
2.2 mirror配置
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://x.x.x.x:9903/nexus/content/repositories/thirdparty/</url>
</mirror>
2.3 profile配置
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus-releases</id>
<url>http://x.x.x.x:9903/nexus/content/repositories/thirdparty/</url>
</repository>
<repository>
<id>nexus-snapshots</id>
<url>http://x.x.x.x:9903/nexus/content/repositories/demoProject/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus-releases</id>
<url>http://x.x.x.x:9903/nexus/content/repositories/thirdparty/</url>
</pluginRepository>
<pluginRepository>
<id>nexus-snapshots</id>
<url>http://x.x.x.x:9903/nexus/content/repositories/demoProject/</url>
</pluginRepository>
</pluginRepositories>
</profile>
2.4 激活profile配置(位置放在 上面就可以了)
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
3 注意事项 1,如果项目是多模块的话,每一个模块一定都要pom配置 2, 如何将组件标记为SNAPSHOT: 在POM文件里,有节点,这个节点如果以SNAPSHOT结尾(注意这里必须是全大写),那么就会识别成SNAPSHOT版,否则就是release版。这里需要注意的是《Maven权威指南》的英文版里说的If a version contains the string “-SNAPSHOT,”是错误的,因为当SNAPSHOT在中间,而不是结尾的时候,比如"1.0-SNAPSHOT-a"仍然会被认为是release版,并且连接符也不需要,比如”1.0SNAPSHOT“也是SNAPSHOT版。 3,如果遇到这个问题
Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project cc-common-api: Failed to deploy artifacts: Could not transfer artifact com.ailpha.cc.cc-common-api:jar:1.0-20210721.070933-1 from/to nexus-snapshots (http://x.x.x.x:9903/nexus/content/repositories/demoProject/): Transfer failed for http://x.x.x.x:9903/nexus/content/repositories/demoProject/com/ailpha/cc/cc-common-api/1.0-SNAPSHOT/cc-common-api-1.0-20210721.070933-1.jar 400 Bad Request
- 如果部署SNAPSHOT的时候,发生400错误,是因为仓库的Type必须是hosted,且Policy必须是Snapshot,否则就是出现400错误。(你配置的SNAPSHOT存放位置)
|