IDEA新建Maven项目时报错

3 篇文章 0 订阅
2 篇文章 0 订阅

E:\Java\jdk1.7.0_80\bin\java.exe -Dmaven.multiModuleProjectDirectory=C:\Users\job012\AppData\Local\Temp\archetype1tmp "-Dmaven.home=E:\IntelliJ IDEA 2018.3.1\plugins\maven\lib\maven3" "-Dclassworlds.conf=E:\IntelliJ IDEA 2018.3.1\plugins\maven\lib\maven3\bin\m2.conf" -Dfile.encoding=UTF-8 -classpath "E:\IntelliJ IDEA 2018.3.1\plugins\maven\lib\maven3\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2018.3.1 -DinteractiveMode=false -DgroupId=SpringDemo1 -DartifactId=SpringDemo1 -Dversion=1.0-SNAPSHOT -DarchetypeGroupId=org.apache.cocoon -DarchetypeArtifactId=cocoon-22-archetype-webapp -DarchetypeVersion=RELEASE org.apache.maven.plugins:maven-archetype-plugin:RELEASE:generate
[INFO] Scanning for projects...
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/maven-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml from/to central (https://repo.maven.apache.org/maven2): Received fatal alert: protocol_version
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.975 s
[INFO] Finished at: 2018-12-13T11:36:19+08:00
[INFO] Final Memory: 7M/153M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-archetype-plugin:RELEASE or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-archetype-plugin:jar:RELEASE: Failed to resolve version for org.apache.maven.plugins:maven-archetype-plugin:jar:RELEASE: Could not find metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml in local (C:\Users\job012\.m2\repository) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
[ERROR] Maven execution terminated abnormally (exit code 1)

 

 出错的项目结构: 

 

 

正确的项目结构:

问题和解决方案

idea的maven一开始是没有setting.xml的,你要去maven的目录里面拷一份setting.xml到你的仓库中。idea的maven在安装路径的plugins文件夹下,即X:\xxx\JetBrains\IntelliJ IDEA 2016.3.2\plugins\plugins\maven\lib\maven3\conf\setting.xml拷贝到你的用户文件夹下的.m2文件夹下,为了之后能够快速的下载依赖包,我们要加一个官方库的镜像,因为maven的官方仓库在国外,太慢了。 
在你的.m2文件夹下的setting.xml中添加如下代码:

<mirror>
      <id>alimaven</id>
      <mirrorOf>central</mirrorOf>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>

这个是阿里的库,所以很快。做完之后我们回到idea,点击next,然后填写项目名,然后finish。 
接下来idea开始创建项目,这里你要把maven自动导入打开。

总结

不止是IDEA自带的Maven没有settings.xml文件,我在使用自己的Maven时,也是出现这种错误,一开始在选择settings.xml文件的时候,都是去找Maven目录下的settings.xml

依然报上面的错误,我的自带Maven仓库是在E:/maven下的。settings.xml是需要放在仓库目录中

注意:maven的位置跟仓库是两个位置

参考博文:

https://www.cnblogs.com/shang-shang/p/7477607.html

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值