idea与maven的版本适配问题

idea对于使用的maven具有兼容性问题

如果出现以下错误

java.lang.RuntimeException: org.codehaus.plexus.component.repository.exception.ComponentLookupException: com.google.inject.ProvisionException: Unable to provision, see the following errors:

1) [Guice/ErrorInjectingConstructor]: NoSuchMethodError: DefaultModelValidator: method 'void <init>()' not found
  at CustomModelValidator.<init>(CustomModelValidator.java:36)
  while locating CustomModelValidator
  at ClassRealm[maven.ext, parent: ClassRealm[plexus.core, parent: null]]
      \_ installed by: WireModule -> PlexusBindingModule
  while locating ModelValidator annotated with @Named(value="ide")

Learn more:
  https://github.com/google/guice/wiki/ERROR_INJECTING_CONSTRUCTOR

1 error

======================
Full classname legend:
======================
CustomModelValidator:  "org.jetbrains.idea.maven.server.embedder.CustomModelValidator"
DefaultModelValidator: "org.apache.maven.model.validation.DefaultModelValidator"
ModelValidator:        "org.apache.maven.model.validation.ModelValidator"
Named:                 "com.google.inject.name.Named"
PlexusBindingModule:   "org.eclipse.sisu.plexus.PlexusBindingModule"
WireModule:            "org.eclipse.sisu.wire.WireModule"
========================
End of classname legend:
========================

      role: org.apache.maven.model.validation.ModelValidator
  roleHint: ide

那么很有可能是因为出现了兼容性问题。

idea版本与maven版本适配如下:
(根据多篇网上博客建议,maven3.6.3,是适配多数项目,尤其是老项目)
idea 2022 兼容maven 3.8.1及之前的所用版本
idea 2021 兼容maven 3.8.1及之前的所用版本
idea 2020 兼容Maven 3.6.3及之前所有版本
idea 2018 兼容Maven3.6.1及之前所有版本
解决方案,可以是重新下载相适配的版本

还有如下

不再配置MAVEN_HOME,选择Bundled (Maven 3)选项,但是项目jar包不会存到到指定目录的包下,会自动生成一个新的

posted @ 2023-05-18 09:23  菜鸟Axin  阅读(3521)  评论(0)    收藏  举报