Unable to import maven project:

2020-02-19  本文已影响0人  WebProgress

一、问题

Unable to import maven project: See logs for details

二、问题出现背景

原项目使用maven默认的仓库镜像,在公司使用拉取速度比较快,编译也速度也可以;回到家中之后,网络卡顿,于是配置国内的阿里云的maven镜像,具体参考[Maven本地配置与使用
,配置成功后,加载maven的相关配置与依赖确实没有问题,也能正常打包jar项目。但是打开另一个maven项目,通过pom.xml打开,发现没有自动导入成功,无法加载依赖文件并报错:Unable to import maven project: See logs for details,项目目录页无法加载出来。

错误

三、问题解决过程

3.1 Idea的settings>>Build,Execution,Deployment>>Build Tools>>Maven>>importing的 JDK for importer设置改为JAVA_HOME环境路径,项目目录加载出来了,但是仍然无法自动加载依赖。
3.2 查看错误日志


查看日志

在默认路径:C:\Users\Administrator\.IntelliJIdea2019.3\system\log中
具体查看自己的具体错误是什么。
此处我的错误为:

ERROR - org.jetbrains.idea.maven - com.google.inject.CreationException: Unable to create injector, see the following errors:

1) No implementation for org.apache.maven.model.path.PathTranslator was bound.
  while locating org.apache.maven.model.path.PathTranslator
    for field at org.apache.maven.model.interpolation.AbstractStringBasedModelInterpolator.pathTranslator(Unknown Source)
  at org.codehaus.plexus.DefaultPlexusContainer$1.configure(DefaultPlexusContainer.java:350)

2) No implementation for org.apache.maven.model.path.UrlNormalizer was bound.
  while locating org.apache.maven.model.path.UrlNormalizer
    for field at org.apache.maven.model.interpolation.AbstractStringBasedModelInterpolator.urlNormalizer(Unknown Source)
  at org.codehaus.plexus.DefaultPlexusContainer$1.configure(DefaultPlexusContainer.java:350)

2 errors 
java.lang.RuntimeException: com.google.inject.CreationException: Unable to create injector, see the following errors:

1) No implementation for org.apache.maven.model.path.PathTranslator was bound.
  while locating org.apache.maven.model.path.PathTranslator
    for field at org.apache.maven.model.interpolation.AbstractStringBasedModelInterpolator.pathTranslator(Unknown Source)
  at org.codehaus.plexus.DefaultPlexusContainer$1.configure(DefaultPlexusContainer.java:350)

2) No implementation for org.apache.maven.model.path.UrlNormalizer was bound.
  while locating org.apache.maven.model.path.UrlNormalizer
    for field at org.apache.maven.model.interpolation.AbstractStringBasedModelInterpolator.urlNormalizer(Unknown Source)
  at org.codehaus.plexus.DefaultPlexusContainer$1.configure(DefaultPlexusContainer.java:350)

此错误是Idea版本与maven插件版本不一致导致的,可以先查看Idea默认的maven版本是多少,再查看自己下载的版本是多少;通过查看发现默认的是3.3.9而自己下载的是3.6.2,版本高,降低版本。

果然,配置跟Idea相对应的maven版本后,打开pom.xml文件能自动加载依赖,项目运行正常。

上一篇下一篇

猜你喜欢

热点阅读