问题描述:cloud2020的pom文件报错怎么办?cloud项目的druid依赖无法下载怎么办?
附:pom文件cloud2020 最初版本[手打版-应该是没啥问题]

1 <?xml version="1.0" encoding="UTF-8"?> 2 3 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 5 <modelVersion>4.0.0</modelVersion> 6 7 <groupId>com.atguigu.springcloud</groupId> 8 <artifactId>cloud2020</artifactId> 9 <version>1.0-SNAPSHOT</version> 10 <packaging>pom</packaging> 11 12 <!--统一管理jar包版本--> 13 <properties> 14 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 15 <maven.compiler.source>1.8</maven.compiler.source> 16 <maven.compiler.target>1.8</maven.compiler.target> 17 <junit.version>4.12</junit.version> 18 <log4j.version>1.2.17</log4j.version> 19 <lombok.version>1.16.18</lombok.version> 20 <mysql.version>5.1.47</mysql.version> 21 <druid.version>1.1.16</druid.version> 22 <mybatis.spring.boot.version>1.3.0</mybatis.spring.boot.version> 23 </properties> 24 25 <dependencyManagement> 26 <dependencies> 27 <!--spring boot 2.2.2--> 28 <dependency> 29 <groupId>org.springframework.boot</groupId> 30 <artifactId>spring-boot-dependencies</artifactId> 31 <version>2.2.2.RELEASE</version> 32 <type>pom</type> 33 <scope>import</scope> 34 </dependency> 35 36 <!--spring cloud Hoxton.SR1--> 37 <dependency> 38 <groupId>org.springframework.cloud</groupId> 39 <artifactId>spring-cloud-dependencies</artifactId> 40 <version>Hoxton.SR1</version> 41 <type>pom</type> 42 <scope>import</scope> 43 </dependency> 44 <!--spring cloud 阿里巴巴 2.1.0--> 45 <dependency> 46 <groupId>com.alibaba.cloud</groupId> 47 <artifactId>spring-cloud-alibaba-dependencies</artifactId> 48 <version>2.1.0.RELEASE</version> 49 <type>pom</type> 50 <scope>import</scope> 51 </dependency> 52 <!--mysql--> 53 <dependency> 54 <groupId>mysql</groupId> 55 <artifactId>mysql-connector-java</artifactId> 56 <version>${mysql.version}</version> 57 <scope>runtime</scope> 58 </dependency> 59 <!-- druid--> 60 <dependency> 61 <groupId>com.alibaba</groupId> 62 <artifactId>druid</artifactId> 63 <version>${druid.version}</version> 64 <!--<version>1.1.15</version>--> 65 <!--15版本 我本地没有 它就没法去下载 但是重新建一个空maven项目,在里面配一下就可以去自动下载, 66 不知道这里是为什么 但是既然老师用的16,那可以先新建一个项目 把16下载到本地仓库 这里就可以使用了。 67 这里除了druid外 还有好几个依赖下载不了的。 如果你本地仓库里,那些依赖都有的话,就不会有这个问题的 68 --> 69 </dependency> 70 <!--mybatis--> 71 <dependency> 72 <groupId>org.mybatis.spring.boot</groupId> 73 <artifactId>mybatis-spring-boot-starter</artifactId> 74 <version>${mybatis.spring.boot.version}</version> 75 </dependency> 76 <!--junit--> 77 <dependency> 78 <groupId>junit</groupId> 79 <artifactId>junit</artifactId> 80 <version>${junit.version}</version> 81 </dependency> 82 <!--log4j--> 83 <dependency> 84 <groupId>log4j</groupId> 85 <artifactId>log4j</artifactId> 86 <version>${log4j.version}</version> 87 </dependency> 88 <dependency> 89 <groupId>org.projectlombok</groupId> 90 <artifactId>lombok</artifactId> 91 <version>${lombok.version}</version> 92 <scope>provided</scope> 93 </dependency> 94 </dependencies> 95 96 </dependencyManagement> 97 98 <build> 99 <plugins> 100 <plugin> 101 <groupId>org.springframework.boot</groupId> 102 <artifactId>spring-boot-maven-plugin</artifactId> 103 <configuration> 104 <fork>true</fork> 105 <addResources>true</addResources> 106 </configuration> 107 </plugin> 108 </plugins> 109 </build> 110 111 </project>
或许你一开始将文件全盘复制到自己的pom里时会出现很多错误。这只是因为你的本地仓库没有这个依赖而已。
但是问题就在这里了。你压根无法下载。
有一些解决思路,
比如,教你【父子工程】
比如,教你【去掉work offline离线,以及其他几个可能的问题】
比如,你的IDEA没有引入本地maven,而是使用了IDEA自带的maven3。
但是,都没解决我的问题,这个cloud2020项目还是无法下载依赖,只能使用本地已有的。
于是,我又找到了另一种可能:你的maven的镜像有问题,可能过旧。
于是,我在【阿里仓库】找到最新的阿里镜像引入我本地maven的setting.xml,

1 <mirror> 2 <id>alimaven</id> 3 <mirrorOf>central</mirrorOf> 4 <name>aliyun maven</name> 5 <url>https://maven.aliyun.com/repository/public</url> 6 </mirror>
你以为这就结束了?并不,这个cloud2020还是无法下载我项目中的依赖。
就在这时,我试着换了一下druid的版本,结果,竟然识别到了我本地已经下载好的版本,就是很老,
这给了我启发:或许,只要把那玩意下载到本地仓库,就可以引入我的项目了。
于是,我去网上各种下载,竟然找不到。这时突发奇想,或许可以新建一个项目,导入它试试。
就这样,我新建了一个maven项目,并且,使用如下代码,果然,可以直接导入我想要的版本。

1 <dependency> 2 <groupId>com.alibaba</groupId> 3 <artifactId>druid</artifactId> 4 <version>1.1.16</version> 5 </dependency>
当本地下载好1.1.16版本的druid后,cloud2020果然一下就识别到了它。
那么,问题很明显了,这个项目似乎无法下载远程仓库的依赖,,,不是我maven镜像的问题。
我尝试了几个办法,还是不行,那个新项目,你要什么版本,只有有的,就能直接下载,但是cloud2020就是不下载。
【这大概就是问题所在,但我暂时无解。先放着。。。】
于是,我用同样的方法,把那些缺失依赖先用新建的那个项目把依赖下载到本地。然后在cloud2020中使用。
先继续项目。坑。【为了后面可能还需要下载依赖,那个专门为了下载pom依赖的新建项目我还留着】
附:https://mvnrepository.com/【可查找依赖都有哪些版本,以及使用的火热程度】
【后记:或许是因为父工程没法下载pom依赖,只能使用本地仓库的。因为在后面的时候,当我在子工程中使用了druid的pom依赖后,它自动给我下载了我设定的版本,并不会出现最开始的那个问题。而值得一提的是,有些人在这一块,pom导入并没有出现这个问题,父工程也可以照常下载引入的各种版本的pom依赖。或许是自身IDEA的配置存在问题?或者版本的问题?或者,看脸??】