在学习maven时,使用webapp骨架、quickstart骨架快速创建项目时,按照视频教程操作,结果Intellij idea无法自动生成src目录,也无法自动导入jar包,很纠结,网上查阅资料,但经过了多次尝试,集百家众长,找到了是适合自己的解决方法,以下是操作步骤。
一、将maven的镜像设置为阿里云的,编辑“maven安装目录/conf/seeting.xml”文件,原有的代码替换为下方代码;
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<!-- 新版的阿里云镜像地址 -->
<url>https://maven.aliyun.com/repository/central</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
二、Intellij Idea在集成maven时,在settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Runner中VM Options输入"-Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -Dmaven.wagon.http.ssl.ignore.validity.dates=true"。记住:maven的设置请在项目打开时进行设置一次,在close project时也设置一次,因为我设置后总是不一致,并确保在创建新的项目时,检查一遍。
结果:使用maven骨架快速创建项目就有src目录了
参考文章:
https://blog.csdn.net/darkness_oldboy/article/details/104083625