maven 与 idea 的一个坑

  • Post author:
  • Post category:其他


第一篇博客记录idea与maven的一个坑

第一篇博客奉献给新公司遇到的第一个问题

当使用maven 3.6.2 与 idea 2018 时

导入一个maven项目,你会惊喜的发现

在这里插入图片描述

项目导入不成功,让你看idea的日志,那么好,找到idea日志

Help –>show log in Explorer

打开报错时间点的日志,发现

2020-07-15 17:26:58,426 [7854877] 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)

2 errors

at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:543)

at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:159)

at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106)

at com.google.inject.Guice.creat

看这异常大概是抛出了一个运行时异常,无法创建一个injector,继续看,org.apache.maven.model.path.PathTranslator这个接口没有发现实现类。那这就不是我们自己能够解决的了,猜测是maven 3.6进行了改动,需要集成工具去实现这个接口进行路径转换之类的操作。

我们这边试试换一个其他的版本,下了一个3.1 版本的maven,再次尝试导入项目


成功

其他版本的maven这边没有去一个个试,有兴趣的小伙伴可以自己去试试,当然换idea的版本也是可行的哦





版权声明:本文为zhouwenbo16原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。