idea创建SpringCloud+Maven多模块项目
1、首先创建父级项目
2、创建Module(以SpringCloud的Eureka为例)
next—>
3、修改pom.xml文件
(1) 父级pom.xml文件
将公用依赖移动到父级pom.xml文件,添加子模块module,红框中是创建模块时自动添加的代理仓库地址,默认的地址下载很慢,修改成下面配置:
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
遇到的问题
Connect to repo.spring.io:443 [repo.spring.io/35.241.58.96] failed: Connection timed out: connect
大致原因就是因为链接不上parent中的pom.xml,所以就会导致报错,在maven/conf/setting.xml中加入以上镜像配置即可(取自https://blog.csdn.net/qq_42773863/article/details/86579465)。
解决方案:
maven的settings.ml文件的标签中添加如下代码段:
<mirror>
<id>mirrorId</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://central.maven.org/maven2/</url>
</mirror>