问题:利用骨架创建maven工程时没有src目录,报错:[ERROR] Maven execution terminated abnormally (exit code 1),就是整个项目骨架没有生成。
1. IDEA中maven的配置问题
配置settings.xml文件
在maven的安装目录中找到conf–>settings.xml找到localRepository,源文件中这个被注释了设置如下:
2. 配置runner的VMoption(下面两种情况的设置需要进一步验证)
(1)同上配置maven打开defaultsetting搜索runner配置如下 :
archetypeCatalog=internal
(2)Maven->Runner: 添加-Dmaven.multiModuleProjectDirectory=$M2_HOME,记得选择JDK
创建maven工程添加一个键值对:archetypeCatalog internal
3. 配置远程中央仓库(***重要***)
一般情况下可以配置为国外的远程中央仓库,但是在国内从国外远程中央仓库下载jar包的速度比较差。如果国内的话,建议使用阿里的远程中央仓库(下载速度快)。配置阿里的远程中央仓库有两种方案:
配置方式一:
conf\setting.xml
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
配置方式二:
在项目的pom.xml中配置:
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
然后新建maven项目
4. 配置Intellij IDEA中自动下载jar包
配置IDEA的maven自动下载源码的方法:
(1)点击File -> Setting ->Maven ->Importing:选中Automatically download中的两个多选框Sources和Documentation
(2)右键maven项目,maven->Reimport,就可自动下载jar包了,下载的jar包到本地仓库中