nexus管理页面上传jar,jar可以被正常拉取到项目,使用idea lifecycle的deploy发布的jar只能拉取到pom,401问题

问题现场

1.项目使用idea maven lifecycle的deploy,关键是直接上传成功了
在这里插入图片描述
nexus上也有这个这个包
在这里插入图片描述
2.其它项目配置nexus地址,拉取该jar

 <!--deploy版本到私服需要该配置,后期可将common等jar放到私服去-->
    <distributionManagement>
        <repository>
            <!--注意该ID必须与与settings.xml配置的server节点配置的id一致,name随意-->
            <id>ksc-maven</id>
            <name>nexus3私服</name>
            <url>${ksc-nexus3}</url>
        </repository>
    </distributionManagement>

    <!--依赖仓库,阿里云及ksc-nexus3私服-->
    <repositories>
        <repository>
            <!--从私服的拉取jar包,id,name随意-->
            <id>xxxx</id>
            <name>nexus3私服</name>
            <url>${ksc-nexus3}</url>
        </repository>
        <repository>
            <id>maven-ali</id>
            <url>http://maven.aliyun.com/nexus/content/groups/public//</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

reimport只有没有jar
在这里插入图片描述
install找不到jar

[ERROR] Failed to execute goal on project vehicle-manage: Could not resolve dependencies for project com.construn:vehicle-manage:jar:0.0.1-SNAPSHOT: Failed to collect dependencies at com.xuxueli:xxl-job-core:jar:2.3.3: Failed to read artifact descriptor for com.xuxueli:xxl-job-core:jar:2.3.3: Could not find artifact com.xuxueli:xxl-job:pom:2.3.3 in xxxx (http://xxxx:xxxx/repository/ksc-maven-mixed/) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException


web页面手动上传测试

可以正常拉取
在这里插入图片描述
在这里插入图片描述

正确deploy姿势

1.使用maven-depoy-plugin发布插件。pom配置maven-deploy-plugin插件再次点击IDEA lifecycle->deploy,因为maven-depoy-plugin插件执行goal挂到了maven生命周期deploy上

    <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.7</version>
        <executions>
          <execution>
            <id>default-deploy</id>
            <phase>deploy</phase>
            <goals>
              <goal>deploy</goal>
            </goals>
            <!-- skip默认deploy插件的执行 -->
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
          <execution>
            <id>deploy-file</id>
            <phase>deploy</phase>
            <goals>
              <goal>deploy-file</goal>
            </goals>
            <configuration>
              <!-- 开发阶段上传到snapshot仓库,上线阶段上传到release仓库 -->
              <repositoryId>ksc-maven</repositoryId>
              <url>http://xxxx/repository/ksc-maven-mixed/</url>
              <file>${project.build.directory}/${project.artifactId}-${project.parent.version}.jar</file>
              <groupId>${project.groupId}</groupId>
              <artifactId>${project.artifactId}</artifactId>
              <version>${project.version}</version>
            </configuration>
          </execution>
        </executions>
      </plugin>

其它问题401

1.检查要发布的jar的pom:distributionManagement->repositry的ID必须与settings.xml中server的id一致,这样maven便会以该ID对应用户的账号密码进行发布,

 <distributionManagement>
        <repository>
            <id>ksc-maven</id>
            <name>ksc-maven-mixed</name>
            <url>http://xxxx/repository/ksc-maven-mixed/</url>
        </repository>
    </distributionManagement>
  <server>
        <id>ksc-maven</id>
        <username>deployer</username>
        <password>deployer</password>
    </server>

2.要保证deployer用户具有ksc-maven-mixed仓库的发布权限
在这里插入图片描述
3.如果还是401,可能是IDE maven参数设置环境问题
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值