每日一菜之maven私服搭建和一些坑

maven私服搭建:

使用Nexus3搭建Maven私服+上传第三方jar包到本地maven仓库 - Endv - 博客园

再附上一个牛批同事的笔记(就是他给解决的):

https://note.youdao.com/ynoteshare/index.html?id=199472fd620ef8ec60f021ba4d6b6bf5&type=notebook&_time=1649837828324

本地项目切换到私服之后遇到的一些问题及解决方案:

问题1、阿里的两个包spring-cloud-starter-hsf、spring-cloud-starter-pandora在Central Repository:中未找到,两种解决方式:

1)、根据官方给的解决方案,这两个包需要单独在maven的settings中配置,参考

​​​​​​配置EDAS的私服地址和轻量级配置及注册中心 - 企业级分布式应用服务 EDAS - 阿里云

但是这个方法需要每个参与项目的小伙伴都要在本地settings中配置,不推荐;

2)、手动把这两个包上传到nexus中;

上传命令:

mvn deploy:deploy-file -DgroupId=org.springframework.cloud -DartifactId=spring-cloud-starter-hsf -Dversion=1.3 -Dpackaging=jar -DpomFile=C:\Users\XXX\Desktop\libdesktop\spring-cloud-starter-hsf-1.3.pom -Dfile=C:\Users\XXX\Desktop\libdesktop\spring-cloud-starter-hsf-1.3.jar -Durl=http://私服ip:8081/repository/maven-releases/ -DrepositoryId=nexus-snapshot

mvn deploy:deploy-file -DgroupId=org.springframework.cloud -DartifactId=spring-cloud-starter-pandora -Dversion=1.3 -Dpackaging=jar -DpomFile=C:\Users\XXX\Desktop\libdesktop\spring-cloud-starter-pandora-1.3.pom -Dfile=C:\Users\XXX\Desktop\libdesktop\spring-cloud-starter-pandora-1.3.jar -Durl=http://私服ip:8081/repository/maven-releases/ -DrepositoryId=nexus-snapshot

问题2、Failed to execute goal on project hsa-ims-business-web-ext: Could not resolve dependencies for project cn.hsa.ims:hsa-ims-business-web-ext:jar:1.0.9: Failed to collect dependen
cies at cn.hsa.ims:hsa-ims-business-web-system:jar:1.0.9-SNAPSHOT -> com.github.ulisesbocchio:jasypt-spring-boot-starter:jar:2.0.0: Failed to read artifact descriptor for com.github.ul
isesbocchio:jasypt-spring-boot-starter:jar:2.0.0: Could not find artifact org.springframework.cloud:spring-cloud-dependencies-parent:pom:2.0.0.RC2 in nexus-aliyun (http://maven.aliyun.
com/nexus/content/groups/public) -> [Help 1]

解决方案:找到上述目录下的资源包,删掉包中的_remote.repositories(想省事的话就直接在本地仓库里直接搜索这个文件,然后全部删除)

问题3、 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project hsa-ims-main-web-ali-ext: Compilation failure: Compilation fail
ure:
[ERROR] /D:/workspace/wonders/gx-20210715/hsa-ims/hsa-ims-web/hsa-ims-main-web-ali-ext/src/main/java/cn/hsa/ims/web/ImsWebApplication.java:[10,52] 程序包springfox.documentation.swagger
2.annotations不存在
[ERROR] /D:/workspace/wonders/gx-20210715/hsa-ims/hsa-ims-web/hsa-ims-main-web-ali-ext/src/main/java/cn/hsa/ims/web/ImsWebApplication.java:[11,2] 找不到符号
[ERROR]   符号: 类 EnableSwagger2

解决方案:找到引用这个包的类所在项目的pom,引入这个依赖,就解决了!!!

记录一下解决这个问题的过程:

这个问题就比较坑了,私服上有这个包,本地仓库也有,pom文件里也引入了,但是就是报错,

首先把原来仓库里的这个包名改了,然后执行mvn install -U,发现竟然下不下来,这个时候我就以为是私服或者是我本地配置的问题了,然后各种百度还是没解决,

根据报错 Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile)有人说是mavn-compiler-plugin的版本问题,应该改成3.1.0,但是项目里确实是3.1.0,

还有人说是idea中的java版本和pom中的jdk版本不一致,应该是1.8,但是我的都是1.8,折腾了1天,有点怀疑人生了,找了大佬解决,大佬了解了问题之后,坐下3分钟解决了问题:

我的项目是父工程包含了4个子工程,父工程的pom文件只是定义了需要的包的版本,实际上并没有引入这个包,如果需要的话要在子工程的pom中引入,实际上我的子工程里并没有引入,所以是我太菜了,赶紧去补一下pom中

dependencyManagement、dependency的区别

版权声明:本文为baidu_35523558原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。