使用IDEA创建Maven项目时报错

使用IDEA创建Maven

创建Maven
注意

报错情况

I:\javapz\jdk1.7\bin\java.exe -Dmaven.multiModuleProjectDirectory=C:\Users\Administrator\AppData\Local\Temp\archetype1tmp "-Dmaven.home=D:\idea\IntelliJ IDEA 2018.1.2\plugins\maven\lib\maven3" "-Dclassworlds.conf=D:\idea\IntelliJ IDEA 2018.1.2\plugins\maven\lib\maven3\bin\m2.conf" -Dfile.encoding=UTF-8 -classpath "D:\idea\IntelliJ IDEA 2018.1.2\plugins\maven\lib\maven3\boot\plexus-classworlds-2.5.2.jar" org.codehaus.classworlds.Launcher -Didea.version=2018.1.2 -DinteractiveMode=false -DgroupId=Test -DartifactId=com.test -Dversion=1.0-SNAPSHOT -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-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: 3.433 s
[INFO] Finished at: 2019-12-06T13:06:03+08:00
[INFO] Final Memory: 6M/121M
[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\Administrator\.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)

错误的项目结构:没有自动创建src等目录
错误的
正确的项目结构:会自动创建出 src>main>webapp>WEB-INF
正确的

解决方案

首先,idea创建的maven一开始是没有setting.xml的
需要从idea的maven在安装路径的plugins文件夹下,即X:\xxx\IntelliJ IDEA 2016.3.2\plugins\maven\lib\maven3\conf\setting.xml 中找到setting.xml文件复制到.m2文件夹下(即上面安装时圈的那个路径)
粘贴位置

提高Maven库导包速度的方法

为了之后能够快速的下载依赖包,我们可以加一个由阿里提供的官方库的镜像,因为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>

代码粘贴位置
接下来就可以创建Maven项目了,记得把自动导入打开,会很方便。
自动导入
ok,这样就没有问题了。

这是本人花了两周时间做出的小程序,感兴趣的可以扫一下,欢迎提取意见

点此链接查看小程序介绍:一款炫酷简洁的记账小程序

在这里插入图片描述

  • 5
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

子休。

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值