我在使用Maven和Java 16时遇到了问题。
问题
当我尝试用maven mvn package
打包我的项目时,我收到了这个错误:
[ERROR] Error executing Maven.
[ERROR] java.lang.IllegalStateException: Unable to load cache item
[ERROR] Caused by: Unable to load cache item
[ERROR] Caused by: Could not initialize class
com.google.inject.internal.cglib.core.$MethodWrapper
按照this website带来的解决方案,我修改了符号链接:
变更前
# ll /usr/share/maven/lib | grep guice
guice.jar -> ../../java/guice.jar
修补程序的应用
# sudo ln -s --force ../../java/guice-4.2.1-no_aop.jar guice.jar
修改后
# ll /usr/share/maven/lib | grep guice
guice.jar -> ../../java/guice-4.2.1-no_aop.jar
但是,这会导致一个新的错误:
# mvn
---------------------------------------------------
constituent[0]: file:/usr/share/maven/conf/logging/
constituent[1]: file:/usr/share/maven/lib/maven-resolver-transport-wagon.jar
constituent[2]: file:/usr/share/maven/lib/maven-core-3.x.jar
constituent[3]: file:/usr/share/maven/lib/guava.jar
constituent[4]: file:/usr/share/maven/lib/maven-compat-3.x.jar
constituent[5]: file:/usr/share/maven/lib/guice.jar
constituent[6]: file:/usr/share/maven/lib/maven-repository-metadata-3.x.jar
constituent[7]: file:/usr/share/maven/lib/maven-slf4j-provider-3.x.jar
constituent[8]: file:/usr/share/maven/lib/commons-io.jar
constituent[9]: file:/usr/share/maven/lib/commons-cli.jar
constituent[10]: file:/usr/share/maven/lib/jansi.jar
constituent[11]: file:/usr/share/maven/lib/maven-settings-3.x.jar
constituent[12]: file:/usr/share/maven/lib/wagon-http-shaded.jar
constituent[13]: file:/usr/share/maven/lib/maven-model-3.x.jar
constituent[14]: file:/usr/share/maven/lib/maven-resolver-impl.jar
constituent[15]: file:/usr/share/maven/lib/wagon-file.jar
constituent[16]: file:/usr/share/maven/lib/sisu-inject.jar
constituent[17]: file:/usr/share/maven/lib/commons-lang3.jar
constituent[18]: file:/usr/share/maven/lib/plexus-interpolation.jar
constituent[19]: file:/usr/share/maven/lib/maven-model-builder-3.x.jar
constituent[20]: file:/usr/share/maven/lib/cdi-api.jar
constituent[21]: file:/usr/share/maven/lib/maven-artifact-3.x.jar
constituent[22]: file:/usr/share/maven/lib/maven-resolver-api.jar
constituent[23]: file:/usr/share/maven/lib/slf4j-api.jar
constituent[24]: file:/usr/share/maven/lib/plexus-sec-dispatcher.jar
constituent[25]: file:/usr/share/maven/lib/wagon-provider-api.jar
constituent[26]: file:/usr/share/maven/lib/maven-resolver-spi.jar
constituent[27]: file:/usr/share/maven/lib/maven-settings-builder-3.x.jar
constituent[28]: file:/usr/share/maven/lib/plexus-component-annotations.jar
constituent[29]: file:/usr/share/maven/lib/aopalliance.jar
constituent[30]: file:/usr/share/maven/lib/plexus-utils.jar
constituent[31]: file:/usr/share/maven/lib/javax.inject.jar
constituent[32]: file:/usr/share/maven/lib/maven-shared-utils.jar
constituent[33]: file:/usr/share/maven/lib/maven-resolver-provider-3.x.jar
constituent[34]: file:/usr/share/maven/lib/maven-resolver-connector-basic.jar
constituent[35]: file:/usr/share/maven/lib/maven-resolver-util.jar
constituent[36]: file:/usr/share/maven/lib/maven-embedder-3.x.jar
constituent[37]: file:/usr/share/maven/lib/maven-builder-support-3.x.jar
constituent[38]: file:/usr/share/maven/lib/jsr250-api.jar
constituent[39]: file:/usr/share/maven/lib/maven-plugin-api-3.x.jar
constituent[40]: file:/usr/share/maven/lib/jcl-over-slf4j.jar
constituent[41]: file:/usr/share/maven/lib/plexus-cipher.jar
constituent[42]: file:/usr/share/maven/lib/sisu-plexus.jar
---------------------------------------------------
Exception in thread "main" java.lang.NoSuchMethodError: 'void com.google.common.base.Preconditions.checkArgument(boolean, java.lang.String, java.lang.Object)'
at com.google.inject.Key.ensureRetainedAtRuntime(Key.java:341)
at com.google.inject.Key.strategyFor(Key.java:335)
at com.google.inject.Key.get(Key.java:219)
at org.eclipse.sisu.wire.ParameterKeys.<clinit>(ParameterKeys.java:28)
at org.eclipse.sisu.wire.DependencyAnalyzer.<init>(DependencyAnalyzer.java:93)
at org.eclipse.sisu.wire.ElementAnalyzer.<init>(ElementAnalyzer.java:104)
at org.eclipse.sisu.wire.WireModule.configure(WireModule.java:74)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:344)
at com.google.inject.spi.Elements.getElements(Elements.java:103)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:137)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
at com.google.inject.Guice.createInjector(Guice.java:87)
at com.google.inject.Guice.createInjector(Guice.java:69)
at com.google.inject.Guice.createInjector(Guice.java:59)
at org.codehaus.plexus.DefaultPlexusContainer.addPlexusInjector(DefaultPlexusContainer.java:481)
at org.codehaus.plexus.DefaultPlexusContainer.<init>(DefaultPlexusContainer.java:206)
at org.apache.maven.cli.MavenCli.container(MavenCli.java:636)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:282)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:567)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
这里的关键字是关于com.google.common.base.Preconditions.checkArgument(boolean, java.lang.String, java.lang.Object)
函数的NoSuchMethodError
,该函数似乎丢失了。
从this question的询问和回答@孟河,我已经尝试重新安装maven,但它没有修复的问题。
我的配置
| 软件|版本|
| - ------| - ------|
| Ubuntu|二○ ○四年一月|
| java |第十六章|
| 梅文|三、六、三|
有可能得到一个建议吗?
先谢谢你的帮助。
2条答案
按热度按时间pokxtpni1#
删除您的发行版的Maven安装并从以下位置下载:https://maven.apache.org/download.cgi并进行安装。问题是基于发行版(Ubuntu或其他)中不断变化的版本,重新打包导致问题的东西。
错误输出中的所有文件或多或少都没有完整的版本号,如(maven-嵌入式-3.x.jar),它位于原始包maven-嵌入式-3.6.1.jar中。
我想您不会通过
mvn --version
获得相同的输出,如下所示:特别是,您不会得到括号中的散列(cecedd 343002696 d 0abb 50 b32 b541 b8 a6 ba 2883 f)
7kqas0il2#
而不是使用grpc-netty-shaded使用