开发环境
- windows 10
- jdk1.8.0_161
- apache-tomcat-9.0.33
开发工具
- apache-maven-3.6.3
- IntelliJ IDEA 2020.1
- Spring Boot 2.3.0
maven 换源
换源的方法有三种:
- 修改
apache-maven-3.6.3/conf
目录中的settings.xml
文件 - 修改 windows 用户目录中生成的
C:\Users\xxx\.m2\settings.xml
- 在
pom.xml
里添加引用源
这里使用第 2 种方法进行配置。使用过 mvn
命令后会自动生成 .m2
文件夹,但是默认是没有 settings.xml
的,需要我们自行创建,我们直接把 apache-maven-3.6.3/conf/settings.xml
文件复制一份进行修改即可。
在 settings.xml
文件里 <mirrors>
标签中添加以下内容。
<!-- 阿里云仓库 -->
<mirror>
<id>AliMaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
因为外国离我们有些远,拉取起来都会很慢,一般拉取远程资源的时候都可以尝试搜索中国源。
IDEA 设置:Setting -> Maven -> User settings file 设置 .m2/settings.xml 并勾上 Override
IntelliJ IDEA Spring Initializr 报错
Initialization failed for 'https://start.spring.io' Please check URL
可以访问也可以正常 ping 通 https://start.spring.io
,但是 IDEA 里就是进不去。处理方法如下:
- IDEA settings 搜索
http proxy
进入 - 勾选
Auto-detect proxy settings
单选项 - 选上
Automatic proxy configuration URL:
- 并随意填写一个本地地址,我用的是
http://127.0.0.1:123
,端口可以随遍填 Check connection
输入https://start.spring.io
点击 OK 显示Connection successful
即证明问题修复了
note: 实在进入不成功,可以直接进入 https://start.spring.io
进行初始化配置,再导入 IDEA 中。