mvn package
我正在尝试使用or使用 maven 构建我的 java 项目,mvn clean install
但我收到此错误:
[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
该项目是使用java 8的简单java项目。
另外,我的电脑上有几个java版本。如果我mvn -X
在 maven 使用 java 16 时运行,我会收到此错误:
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 16.0.2, vendor: Oracle Corporation, runtime: /usr/lib/jvm/jdk-16.0.2
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.11.0-25-generic", arch: "amd64", family: "unix"
[ERROR] Error executing Maven.
com.google.common.util.concurrent.UncheckedExecutionException: java.lang.IllegalStateException: Unable to load cache item
at com.google.common.cache.LocalCache$Segment.get (LocalCache.java:2205)
at com.google.common.cache.LocalCache.get (LocalCache.java:3951)
at com.google.common.cache.LocalCache.getOrLoad (LocalCache.java:3955)
at com.google.common.cache.LocalCache$LocalLoadingCache.get (LocalCache.java:4870)
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked (LocalCache.java:4876)
at com.google.inject.internal.FailableCache.get (FailableCache.java:51)
at com.google.inject.internal.ConstructorInjectorStore.get (ConstructorInjectorStore.java:48)
at com.google.inject.internal.ConstructorBindingImpl.initialize (ConstructorBindingImpl.java:155)
at com.google.inject.internal.InjectorImpl.initializeBinding (InjectorImpl.java:581)
at com.google.inject.internal.AbstractBindingProcessor$Processor$1.run (AbstractBindingProcessor.java:176)
at com.google.inject.internal.ProcessedBindingData.initializeBindings (ProcessedBindingData.java:49)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically (InternalInjectorCreator.java:122)
at com.google.inject.internal.InternalInjectorCreator.build (InternalInjectorCreator.java:106)
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 jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at 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)
Caused by: java.lang.IllegalStateException: Unable to load cache item
at com.google.inject.internal.cglib.core.internal.$LoadingCache.createEntry (LoadingCache.java:79)
at com.google.inject.internal.cglib.core.internal.$LoadingCache.get (LoadingCache.java:34)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData.get (AbstractClassGenerator.java:116)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator.create (AbstractClassGenerator.java:291)
at com.google.inject.internal.cglib.reflect.$FastClass$Generator.create (FastClass.java:65)
at com.google.inject.internal.BytecodeGen.newFastClassForMember (BytecodeGen.java:258)
at com.google.inject.internal.BytecodeGen.newFastClassForMember (BytecodeGen.java:207)
at com.google.inject.internal.DefaultConstructionProxyFactory.create (DefaultConstructionProxyFactory.java:49)
at com.google.inject.internal.ProxyFactory.create (ProxyFactory.java:156)
at com.google.inject.internal.ConstructorInjectorStore.createConstructor (ConstructorInjectorStore.java:92)
at com.google.inject.internal.ConstructorInjectorStore.access$000 (ConstructorInjectorStore.java:29)
at com.google.inject.internal.ConstructorInjectorStore$1.create (ConstructorInjectorStore.java:37)
at com.google.inject.internal.ConstructorInjectorStore$1.create (ConstructorInjectorStore.java:33)
at com.google.inject.internal.FailableCache$1.load (FailableCache.java:40)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture (LocalCache.java:3540)
at com.google.common.cache.LocalCache$Segment.loadSync (LocalCache.java:2321)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad (LocalCache.java:2284)
at com.google.common.cache.LocalCache$Segment.get (LocalCache.java:2199)
at com.google.common.cache.LocalCache.get (LocalCache.java:3951)
at com.google.common.cache.LocalCache.getOrLoad (LocalCache.java:3955)
at com.google.common.cache.LocalCache$LocalLoadingCache.get (LocalCache.java:4870)
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked (LocalCache.java:4876)
at com.google.inject.internal.FailableCache.get (FailableCache.java:51)
at com.google.inject.internal.ConstructorInjectorStore.get (ConstructorInjectorStore.java:48)
at com.google.inject.internal.ConstructorBindingImpl.initialize (ConstructorBindingImpl.java:155)
at com.google.inject.internal.InjectorImpl.initializeBinding (InjectorImpl.java:581)
at com.google.inject.internal.AbstractBindingProcessor$Processor$1.run (AbstractBindingProcessor.java:176)
at com.google.inject.internal.ProcessedBindingData.initializeBindings (ProcessedBindingData.java:49)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically (InternalInjectorCreator.java:122)
at com.google.inject.internal.InternalInjectorCreator.build (InternalInjectorCreator.java:106)
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 jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at 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)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.google.inject.internal.cglib.core.$MethodWrapper
at com.google.inject.internal.cglib.core.$DuplicatesPredicate.evaluate (DuplicatesPredicate.java:104)
at com.google.inject.internal.cglib.core.$CollectionUtils.filter (CollectionUtils.java:52)
at com.google.inject.internal.cglib.reflect.$FastClassEmitter.<init> (FastClassEmitter.java:69)
at com.google.inject.internal.cglib.reflect.$FastClass$Generator.generateClass (FastClass.java:77)
at com.google.inject.internal.cglib.core.$DefaultGeneratorStrategy.generate (DefaultGeneratorStrategy.java:25)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator.generate (AbstractClassGenerator.java:329)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData$3.apply (AbstractClassGenerator.java:93)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData$3.apply (AbstractClassGenerator.java:91)
at com.google.inject.internal.cglib.core.internal.$LoadingCache$2.call (LoadingCache.java:54)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at com.google.inject.internal.cglib.core.internal.$LoadingCache.createEntry (LoadingCache.java:61)
at com.google.inject.internal.cglib.core.internal.$LoadingCache.get (LoadingCache.java:34)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator$ClassLoaderData.get (AbstractClassGenerator.java:116)
at com.google.inject.internal.cglib.core.$AbstractClassGenerator.create (AbstractClassGenerator.java:291)
at com.google.inject.internal.cglib.reflect.$FastClass$Generator.create (FastClass.java:65)
at com.google.inject.internal.BytecodeGen.newFastClassForMember (BytecodeGen.java:258)
at com.google.inject.internal.BytecodeGen.newFastClassForMember (BytecodeGen.java:207)
at com.google.inject.internal.DefaultConstructionProxyFactory.create (DefaultConstructionProxyFactory.java:49)
at com.google.inject.internal.ProxyFactory.create (ProxyFactory.java:156)
at com.google.inject.internal.ConstructorInjectorStore.createConstructor (ConstructorInjectorStore.java:92)
at com.google.inject.internal.ConstructorInjectorStore.access$000 (ConstructorInjectorStore.java:29)
at com.google.inject.internal.ConstructorInjectorStore$1.create (ConstructorInjectorStore.java:37)
at com.google.inject.internal.ConstructorInjectorStore$1.create (ConstructorInjectorStore.java:33)
at com.google.inject.internal.FailableCache$1.load (FailableCache.java:40)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture (LocalCache.java:3540)
at com.google.common.cache.LocalCache$Segment.loadSync (LocalCache.java:2321)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad (LocalCache.java:2284)
at com.google.common.cache.LocalCache$Segment.get (LocalCache.java:2199)
at com.google.common.cache.LocalCache.get (LocalCache.java:3951)
at com.google.common.cache.LocalCache.getOrLoad (LocalCache.java:3955)
at com.google.common.cache.LocalCache$LocalLoadingCache.get (LocalCache.java:4870)
at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked (LocalCache.java:4876)
at com.google.inject.internal.FailableCache.get (FailableCache.java:51)
at com.google.inject.internal.ConstructorInjectorStore.get (ConstructorInjectorStore.java:48)
at com.google.inject.internal.ConstructorBindingImpl.initialize (ConstructorBindingImpl.java:155)
at com.google.inject.internal.InjectorImpl.initializeBinding (InjectorImpl.java:581)
at com.google.inject.internal.AbstractBindingProcessor$Processor$1.run (AbstractBindingProcessor.java:176)
at com.google.inject.internal.ProcessedBindingData.initializeBindings (ProcessedBindingData.java:49)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically (InternalInjectorCreator.java:122)
at com.google.inject.internal.InternalInjectorCreator.build (InternalInjectorCreator.java:106)
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 jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:78)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at 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)
如果我将 maven 使用的 java 版本更改为 1.8 版,我会得到:
Maven home: /usr/share/maven
Java version: 1.8.0_292, vendor: Private Build, runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.11.0-25-generic", arch: "amd64", family: "unix"
[DEBUG] Created new class realm maven.api
[DEBUG] Importing foreign packages into class realm maven.api
[DEBUG] Imported: javax.annotation.* < plexus.core
[DEBUG] Imported: javax.annotation.security.* < plexus.core
[DEBUG] Imported: javax.enterprise.inject.* < plexus.core
[DEBUG] Imported: javax.enterprise.util.* < plexus.core
[DEBUG] Imported: javax.inject.* < plexus.core
[DEBUG] Imported: org.apache.maven.* < plexus.core
[DEBUG] Imported: org.apache.maven.artifact < plexus.core
[DEBUG] Imported: org.apache.maven.classrealm < plexus.core
[DEBUG] Imported: org.apache.maven.cli < plexus.core
[DEBUG] Imported: org.apache.maven.configuration < plexus.core
[DEBUG] Imported: org.apache.maven.exception < plexus.core
[DEBUG] Imported: org.apache.maven.execution < plexus.core
[DEBUG] Imported: org.apache.maven.execution.scope < plexus.core
[DEBUG] Imported: org.apache.maven.lifecycle < plexus.core
[DEBUG] Imported: org.apache.maven.model < plexus.core
[DEBUG] Imported: org.apache.maven.monitor < plexus.core
[DEBUG] Imported: org.apache.maven.plugin < plexus.core
[DEBUG] Imported: org.apache.maven.profiles < plexus.core
[DEBUG] Imported: org.apache.maven.project < plexus.core
[DEBUG] Imported: org.apache.maven.reporting < plexus.core
[DEBUG] Imported: org.apache.maven.repository < plexus.core
[DEBUG] Imported: org.apache.maven.rtinfo < plexus.core
[DEBUG] Imported: org.apache.maven.settings < plexus.core
[DEBUG] Imported: org.apache.maven.toolchain < plexus.core
[DEBUG] Imported: org.apache.maven.usability < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.* < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.authentication < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.authorization < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.events < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.observers < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.proxy < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.repository < plexus.core
[DEBUG] Imported: org.apache.maven.wagon.resource < plexus.core
[DEBUG] Imported: org.codehaus.classworlds < plexus.core
[DEBUG] Imported: org.codehaus.plexus.* < plexus.core
[DEBUG] Imported: org.codehaus.plexus.classworlds < plexus.core
[DEBUG] Imported: org.codehaus.plexus.component < plexus.core
[DEBUG] Imported: org.codehaus.plexus.configuration < plexus.core
[DEBUG] Imported: org.codehaus.plexus.container < plexus.core
[DEBUG] Imported: org.codehaus.plexus.context < plexus.core
[DEBUG] Imported: org.codehaus.plexus.lifecycle < plexus.core
[DEBUG] Imported: org.codehaus.plexus.logging < plexus.core
[DEBUG] Imported: org.codehaus.plexus.personality < plexus.core
[DEBUG] Imported: org.codehaus.plexus.util.xml.Xpp3Dom < plexus.core
[DEBUG] Imported: org.codehaus.plexus.util.xml.pull.XmlPullParser < plexus.core
[DEBUG] Imported: org.codehaus.plexus.util.xml.pull.XmlPullParserException < plexus.core
[DEBUG] Imported: org.codehaus.plexus.util.xml.pull.XmlSerializer < plexus.core
[DEBUG] Imported: org.eclipse.aether.* < plexus.core
[DEBUG] Imported: org.eclipse.aether.artifact < plexus.core
[DEBUG] Imported: org.eclipse.aether.collection < plexus.core
[DEBUG] Imported: org.eclipse.aether.deployment < plexus.core
[DEBUG] Imported: org.eclipse.aether.graph < plexus.core
[DEBUG] Imported: org.eclipse.aether.impl < plexus.core
[DEBUG] Imported: org.eclipse.aether.installation < plexus.core
[DEBUG] Imported: org.eclipse.aether.internal.impl < plexus.core
[DEBUG] Imported: org.eclipse.aether.metadata < plexus.core
[DEBUG] Imported: org.eclipse.aether.repository < plexus.core
[DEBUG] Imported: org.eclipse.aether.resolution < plexus.core
[DEBUG] Imported: org.eclipse.aether.spi < plexus.core
[DEBUG] Imported: org.eclipse.aether.transfer < plexus.core
[DEBUG] Imported: org.eclipse.aether.version < plexus.core
[DEBUG] Imported: org.fusesource.jansi.* < plexus.core
[DEBUG] Imported: org.slf4j.* < plexus.core
[DEBUG] Imported: org.slf4j.event.* < plexus.core
[DEBUG] Imported: org.slf4j.helpers.* < plexus.core
[DEBUG] Imported: org.slf4j.spi.* < plexus.core
[DEBUG] Populating class realm maven.api
[INFO] Error stacktraces are turned on.
[DEBUG] Message scheme: color
[DEBUG] Message styles: debug info warning error success failure strong mojo project
[DEBUG] Reading global settings from /usr/share/maven/conf/settings.xml
[DEBUG] Reading user settings from /home/emin/.m2/settings.xml
[DEBUG] Reading global toolchains from /usr/share/maven/conf/toolchains.xml
[DEBUG] Reading user toolchains from /home/emin/.m2/toolchains.xml
[DEBUG] Using local repository at /home/emin/.m2/repository
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /home/emin/.m2/repository
[INFO] Scanning for projects...
[DEBUG] Extension realms for project org.apache.maven:standalone-pom:pom:1: (none)
[DEBUG] Looking up lifecycle mappings for packaging pom from ClassRealm[plexus.core, parent: null]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.106 s
[INFO] Finished at: 2021-08-11T16:41:45+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
org.apache.maven.lifecycle.NoGoalSpecifiedException: No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy.
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:97)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:498)
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)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException
还,
emin@meb:~$ mvn --version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 11.0.11, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.11.0-25-generic", arch: "amd64", family: "unix"
谁能解释一下原因。