maven项目报错

clipboard.png

报错信息

Could not resolve archetype org.apache.maven.archetypes:maven-archetype-webapp:1.0 from any of the configured repositories.
Could not resolve artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0
Failure to transfer org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from https://repo.maven.apache.org... was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from/to central (https://repo.maven.apache.org... Server sent an unsupported extension: type_35
Failure to transfer org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from https://repo.maven.apache.org... was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.archetypes:maven-archetype-webapp:pom:1.0 from/to central (https://repo.maven.apache.org... Server sent an unsupported extension: type_35

如上述信息,试了几种方法,均未解决,只好来求助(老项目jar包下一半报错,任何maven新项目创建不了)我的maven的版本是3.5.0
ps:重装系统之前还能使用,难道和系统有关系吗?

阅读 3.4k
2 个回答

这个应该是你本地的repository中没有你要使用的archetype造成的,你试一下在创建maven项目的时候不使用任何archetype应该会成功。
至于原因是因为当是用archetype创建maven项目的时候,如果本地没有archetype相关依赖,这个时候maven会去中央仓库下载对应依赖,而maven中央仓库下载速度太慢,如果下载失败,就会报你上面的错误。另外推荐用国内的仓库,配置方式如下:

  1. 打开Maven配置文件Setting.xml,如下:

    vim /Users/xxx/.m2/settings.xml

  2. 在配置文件中添加如下配置:

    <mirrors>

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

    </mirrors>

输入:wq保存即可
上面是macOS的配置方法,windows可以参考上面的配置

你尝试一下重装maven

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题