idea项目配置nexus

两个位置
项目第三方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

  1. 如果部署SNAPSHOT的时候,发生400错误,是因为仓库的Type必须是hosted,且Policy必须是Snapshot,否则就是出现400错误。(你配置的SNAPSHOT存放位置)
    在这里插入图片描述
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大道至简@EveryDay

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值