根据Maven的发布历史,应该可以在JDK7上运行Maven的任何最新版本(在编写本文时)。但是,当我在Ubuntu21.04机器上尝试这样做时,我得到了一个错误:java.lang.unsupportedClassVersionerror:com/google/inject/module:Unsupported Major.minor version 52.0
。
即使在不包含任何Java文件或pom.xml
文件的目录中运行mvn
而没有任何参数时也会发生这种情况。
Maven信息:
└─❯ mvn -version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 1.7.0_80, vendor: Oracle Corporation, runtime: /home/jqno/.jabba/jdk/1.7.80-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.11.0-16-generic", arch: "amd64", family: "unix"
(我还安装了Zulu1.7.292和OpenJDK;那里的行为是相同的。)
└─❯ mvn clean
---------------------------------------------------
constituent[0]: file:/usr/share/maven/conf/logging/
constituent[1]: file:/usr/share/maven/lib/commons-lang3.jar
constituent[2]: file:/usr/share/maven/lib/sisu-plexus.jar
constituent[3]: file:/usr/share/maven/lib/maven-core-3.x.jar
constituent[4]: file:/usr/share/maven/lib/maven-shared-utils.jar
constituent[5]: file:/usr/share/maven/lib/sisu-inject.jar
constituent[6]: file:/usr/share/maven/lib/jansi.jar
constituent[7]: file:/usr/share/maven/lib/plexus-component-annotations.jar
constituent[8]: file:/usr/share/maven/lib/plexus-interpolation.jar
constituent[9]: file:/usr/share/maven/lib/maven-settings-builder-3.x.jar
constituent[10]: file:/usr/share/maven/lib/aopalliance.jar
constituent[11]: file:/usr/share/maven/lib/wagon-provider-api.jar
constituent[12]: file:/usr/share/maven/lib/jsr250-api.jar
constituent[13]: file:/usr/share/maven/lib/slf4j-api.jar
constituent[14]: file:/usr/share/maven/lib/plexus-cipher.jar
constituent[15]: file:/usr/share/maven/lib/maven-slf4j-provider-3.x.jar
constituent[16]: file:/usr/share/maven/lib/maven-resolver-transport-wagon.jar
constituent[17]: file:/usr/share/maven/lib/wagon-file.jar
constituent[18]: file:/usr/share/maven/lib/plexus-sec-dispatcher.jar
constituent[19]: file:/usr/share/maven/lib/maven-resolver-provider-3.x.jar
constituent[20]: file:/usr/share/maven/lib/jcl-over-slf4j.jar
constituent[21]: file:/usr/share/maven/lib/wagon-http-shaded.jar
constituent[22]: file:/usr/share/maven/lib/maven-compat-3.x.jar
constituent[23]: file:/usr/share/maven/lib/guice-no-aop.jar
constituent[24]: file:/usr/share/maven/lib/maven-artifact-3.x.jar
constituent[25]: file:/usr/share/maven/lib/guava.jar
constituent[26]: file:/usr/share/maven/lib/maven-resolver-connector-basic.jar
constituent[27]: file:/usr/share/maven/lib/commons-cli.jar
constituent[28]: file:/usr/share/maven/lib/maven-builder-support-3.x.jar
constituent[29]: file:/usr/share/maven/lib/maven-resolver-api.jar
constituent[30]: file:/usr/share/maven/lib/plexus-utils.jar
constituent[31]: file:/usr/share/maven/lib/maven-settings-3.x.jar
constituent[32]: file:/usr/share/maven/lib/maven-resolver-util.jar
constituent[33]: file:/usr/share/maven/lib/maven-resolver-impl.jar
constituent[34]: file:/usr/share/maven/lib/cdi-api.jar
constituent[35]: file:/usr/share/maven/lib/maven-resolver-spi.jar
constituent[36]: file:/usr/share/maven/lib/maven-embedder-3.x.jar
constituent[37]: file:/usr/share/maven/lib/maven-repository-metadata-3.x.jar
constituent[38]: file:/usr/share/maven/lib/commons-io.jar
constituent[39]: file:/usr/share/maven/lib/maven-model-builder-3.x.jar
constituent[40]: file:/usr/share/maven/lib/maven-plugin-api-3.x.jar
constituent[41]: file:/usr/share/maven/lib/maven-model-3.x.jar
constituent[42]: file:/usr/share/maven/lib/javax.inject.jar
---------------------------------------------------
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/google/inject/Module : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:425)
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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)
这里的问题是Ubuntu重新打包了Maven,结果导致了这个问题。
如这里所示,如果您通过以下途径检查版本:
mvn --version
Apache Maven 3.6.3
Maven home: /usr/share/maven
Java version: 1.7.0_80, vendor: Oracle Corporation, runtime: /home/jqno/.jabba/jdk/1.7.80-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.11.0-16-generic", arch: "amd64", family: "unix"
这表明您使用的不是Apache Maven。
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /Users/XXX/tools/maven
Java version: 1.7.0_302, vendor: Azul Systems, Inc., runtime: /Users/khmarbaise/.sdkman/candidates/java/7.0.302-zulu/zulu-7.jdk/Contents/Home/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
constituent[0]: file:/usr/share/maven/conf/logging/
constituent[1]: file:/usr/share/maven/lib/commons-lang3.jar
constituent[2]: file:/usr/share/maven/lib/sisu-plexus.jar
constituent[3]: file:/usr/share/maven/lib/maven-core-3.x.jar
constituent[4]: file:/usr/share/maven/lib/maven-shared-utils.jar
constituent[5]: file:/usr/share/maven/lib/sisu-inject.jar
constituent[6]: file:/usr/share/maven/lib/jansi.jar
constituent[7]: file:/usr/share/maven/lib/plexus-component-annotations.jar
constituent[8]: file:/usr/share/maven/lib/plexus-interpolation.jar
constituent[9]: file:/usr/share/maven/lib/maven-settings-builder-3.x.jar
constituent[10]: file:/usr/share/maven/lib/aopalliance.jar
constituent[11]: file:/usr/share/maven/lib/wagon-provider-api.jar
constituent[12]: file:/usr/share/maven/lib/jsr250-api.jar
constituent[13]: file:/usr/share/maven/lib/slf4j-api.jar
constituent[14]: file:/usr/share/maven/lib/plexus-cipher.jar
constituent[15]: file:/usr/share/maven/lib/maven-slf4j-provider-3.x.jar
constituent[16]: file:/usr/share/maven/lib/maven-resolver-transport-wagon.jar
constituent[17]: file:/usr/share/maven/lib/wagon-file.jar
constituent[18]: file:/usr/share/maven/lib/plexus-sec-dispatcher.jar
constituent[19]: file:/usr/share/maven/lib/maven-resolver-provider-3.x.jar
constituent[20]: file:/usr/share/maven/lib/jcl-over-slf4j.jar
constituent[21]: file:/usr/share/maven/lib/wagon-http-shaded.jar
constituent[22]: file:/usr/share/maven/lib/maven-compat-3.x.jar
constituent[23]: file:/usr/share/maven/lib/guice-no-aop.jar
constituent[24]: file:/usr/share/maven/lib/maven-artifact-3.x.jar
constituent[25]: file:/usr/share/maven/lib/guava.jar
constituent[26]: file:/usr/share/maven/lib/maven-resolver-connector-basic.jar
constituent[27]: file:/usr/share/maven/lib/commons-cli.jar
constituent[28]: file:/usr/share/maven/lib/maven-builder-support-3.x.jar
constituent[29]: file:/usr/share/maven/lib/maven-resolver-api.jar
constituent[30]: file:/usr/share/maven/lib/plexus-utils.jar
constituent[31]: file:/usr/share/maven/lib/maven-settings-3.x.jar
constituent[32]: file:/usr/share/maven/lib/maven-resolver-util.jar
constituent[33]: file:/usr/share/maven/lib/maven-resolver-impl.jar
constituent[34]: file:/usr/share/maven/lib/cdi-api.jar
constituent[35]: file:/usr/share/maven/lib/maven-resolver-spi.jar
constituent[36]: file:/usr/share/maven/lib/maven-embedder-3.x.jar
constituent[37]: file:/usr/share/maven/lib/maven-repository-metadata-3.x.jar
constituent[38]: file:/usr/share/maven/lib/commons-io.jar
constituent[39]: file:/usr/share/maven/lib/maven-model-builder-3.x.jar
constituent[40]: file:/usr/share/maven/lib/maven-plugin-api-3.x.jar
constituent[41]: file:/usr/share/maven/lib/maven-model-3.x.jar
constituent[42]: file:/usr/share/maven/lib/javax.inject.jar
constituent[3]: file:/usr/share/maven/lib/maven-core-3.x.jar
..
constituent[25]: file:/usr/share/maven/lib/guice-no-aop.jar
如果查看原始的Apache Maven lib目录,文件如下所示:
javaee (master *)$ ls -la ~/tools/apache-maven-3.6.3/lib/
total 21000
drwxr-xr-x 65 khmarbaise staff 2080 Nov 7 2019 .
drwxr-xr-x 9 khmarbaise staff 288 Nov 21 2019 ..
-rw-r--r-- 1 khmarbaise staff 44908 Nov 7 2019 cdi-api-1.0.jar
-rw-r--r-- 1 khmarbaise staff 11560 Nov 7 2019 cdi-api.license
-rw-r--r-- 1 khmarbaise staff 53820 Nov 7 2019 commons-cli-1.4.jar
-rw-r--r-- 1 khmarbaise staff 11560 Nov 7 2019 commons-cli.license
-rw-r--r-- 1 khmarbaise staff 208700 Nov 7 2019 commons-io-2.5.jar
-rw-r--r-- 1 khmarbaise staff 11560 Nov 7 2019 commons-io.license
-rw-r--r-- 1 khmarbaise staff 501879 Nov 7 2019 commons-lang3-3.8.1.jar
-rw-r--r-- 1 khmarbaise staff 11560 Nov 7 2019 commons-lang3.license
drwxr-xr-x 3 khmarbaise staff 96 Nov 7 2019 ext
-rw-r--r-- 1 khmarbaise staff 2591373 Nov 7 2019 guava-25.1-android.jar
-rw-r--r-- 1 khmarbaise staff 11560 Nov 7 2019 guava.license
-rw-r--r-- 1 khmarbaise staff 520662 Nov 7 2019 guice-4.2.1-no_aop.jar
-rw-r--r-- 1 khmarbaise staff 11560 Nov 7 2019 guice.license
-rw-r--r-- 1 khmarbaise staff 283858 Nov 7 2019 jansi-1.17.1.jar
drwxr-xr-x 10 khmarbaise staff 320 Nov 7 2019 jansi-native
-rw-r--r-- 1 khmarbaise staff 11560 Nov 7 2019 jansi.license
-rw-r--r-- 1 khmarbaise staff 2497 Nov 7 2019 javax.inject-1.jar
-rw-r--r-- 1 khmarbaise staff 11560 Nov 7 2019 javax.inject.license
-rw-r--r-- 1 khmarbaise staff 16539 Nov 7 2019 jcl-over-slf4j-1.7.29.jar
-rw-r--r-- 1 khmarbaise staff 11560 Nov 7 2019 jcl-over-slf4j.license
-rw-r--r-- 1 khmarbaise staff 397115 Nov 7 2019 jsoup-1.12.1.jar
-rw-r--r-- 1 khmarbaise staff 1192 Nov 7 2019 jsoup.license
-rw-r--r-- 1 khmarbaise staff 5848 Nov 7 2019 jsr250-api-1.0.jar
-rw-r--r-- 1 khmarbaise staff 20545 Nov 7 2019 jsr250-api.license
-rw-r--r-- 1 khmarbaise staff 57824 Nov 7 2019 maven-artifact-3.6.3.jar
-rw-r--r-- 1 khmarbaise staff 14262 Nov 7 2019 maven-builder-support-3.6.3.jar
-rw-r--r-- 1 khmarbaise staff 287955 Nov 7 2019 maven-compat-3.6.3.jar
-rw-r--r-- 1 khmarbaise staff 633028 Nov 7 2019 maven-core-3.6.3.jar
-rw-r--r-- 1 khmarbaise staff 98096 Nov 7 2019 maven-embedder-3.6.3.jar
-rw-r--r-- 1 khmarbaise staff 215412 Nov 7 2019 maven-model-3.6.3.jar
-rw-r--r-- 1 khmarbaise staff 192302 Nov 7 2019 maven-model-builder-3.6.3.jar
-rw-r--r-- 1 khmarbaise staff 47035 Nov 7 2019 maven-plugin-api-3.6.3.jar
-rw-r--r-- 1 khmarbaise staff 27158 Nov 7 2019 maven-repository-metadata-3.6.3.jar
-rw-r--r-- 1 khmarbaise staff 148983 Nov 7 2019 maven-resolver-api-1.4.1.jar
-rw-r--r-- 1 khmarbaise staff 44143 Nov 7 2019 maven-resolver-connector-basic-1.4.1.jar
-rw-r--r-- 1 khmarbaise staff 180696 Nov 7 2019 maven-resolver-impl-1.4.1.jar
-rw-r--r-- 1 khmarbaise staff 66242 Nov 7 2019 maven-resolver-provider-3.6.3.jar
-rw-r--r-- 1 khmarbaise staff 36732 Nov 7 2019 maven-resolver-spi-1.4.1.jar
-rw-r--r-- 1 khmarbaise staff 31013 Nov 7 2019 maven-resolver-transport-wagon-1.4.1.jar
-rw-r--r-- 1 khmarbaise staff 167529 Nov 7 2019 maven-resolver-util-1.4.1.jar
-rw-r--r-- 1 khmarbaise staff 44047 Nov 7 2019 maven-settings-3.6.3.jar
-rw-r--r-- 1 khmarbaise staff 42090 Nov 7 2019 maven-settings-builder-3.6.3.jar
-rw-r--r-- 1 khmarbaise staff 166562 Nov 7 2019 maven-shared-utils-3.2.1.jar
-rw-r--r-- 1 khmarbaise staff 23815 Nov 7 2019 maven-slf4j-provider-3.6.3.jar
-rw-r--r-- 1 khmarbaise staff 379197 Nov 7 2019 org.eclipse.sisu.inject-0.3.4.jar
-rw-r--r-- 1 khmarbaise staff 11530 Nov 7 2019 org.eclipse.sisu.inject.license
-rw-r--r-- 1 khmarbaise staff 205323 Nov 7 2019 org.eclipse.sisu.plexus-0.3.4.jar
-rw-r--r-- 1 khmarbaise staff 11530 Nov 7 2019 org.eclipse.sisu.plexus.license
-rw-r--r-- 1 khmarbaise staff 13350 Nov 7 2019 plexus-cipher-1.7.jar
-rw-r--r-- 1 khmarbaise staff 11560 Nov 7 2019 plexus-cipher.license
-rw-r--r-- 1 khmarbaise staff 4225 Nov 7 2019 plexus-component-annotations-2.1.0.jar
-rw-r--r-- 1 khmarbaise staff 11560 Nov 7 2019 plexus-component-annotations.license
-rw-r--r-- 1 khmarbaise staff 85327 Nov 7 2019 plexus-interpolation-1.25.jar
-rw-r--r-- 1 khmarbaise staff 11560 Nov 7 2019 plexus-interpolation.license
-rw-r--r-- 1 khmarbaise staff 27703 Nov 7 2019 plexus-sec-dispatcher-1.4.jar
-rw-r--r-- 1 khmarbaise staff 11560 Nov 7 2019 plexus-sec-dispatcher.license
-rw-r--r-- 1 khmarbaise staff 261801 Nov 7 2019 plexus-utils-3.2.1.jar
-rw-r--r-- 1 khmarbaise staff 11560 Nov 7 2019 plexus-utils.license
-rw-r--r-- 1 khmarbaise staff 41424 Nov 7 2019 slf4j-api-1.7.29.jar
-rw-r--r-- 1 khmarbaise staff 1224 Nov 7 2019 slf4j-api.license
-rw-r--r-- 1 khmarbaise staff 11586 Nov 7 2019 wagon-file-3.3.4.jar
-rw-r--r-- 1 khmarbaise staff 2206349 Nov 7 2019 wagon-http-3.3.4-shaded.jar
-rw-r--r-- 1 khmarbaise staff 55776 Nov 7 2019 wagon-provider-api-3.3.4.jar
所有像maven-core..
等文件都包含Maven(3.6.3)的版本号
-rw-r--r-- 1 khmarbaise staff 2591373 Nov 7 2019 guava-25.1-android.jar
-rw-r--r-- 1 khmarbaise staff 11560 Nov 7 2019 guava.license
-rw-r--r-- 1 khmarbaise staff 520662 Nov 7 2019 guice-4.2.1-no_aop.jar
-rw-r--r-- 1 khmarbaise staff 11560 Nov 7 2019 guice.license
您可以看到,这与给定的输出特别不同,其中只有文件:/usr/share/maven/lib/guice-4.2.1-no_aop.jar
,其他工件的版本号缺失。
另外,您还可以下载Apache Maven并将文件的校验和与您的decredo的校验和(/usr/share/Maven/lib/
)进行检查,我敢打赌,所有文件都是不同的。
这个问题是基于distros的想法,它将应用程序(例如Maven)与它们系统上的依赖项重新打包,这实际上意味着您有不同版本的依赖项,这就导致了这样的问题。
我使用Mac OS X10.8.2和JDK7。现在我下载了IDEA Intellij11的最新版本。但如果没有JDK6,它似乎不会开始。有什么变通办法吗? 如何在Mac OS X上使用JDK7运行IDEA IntelliJ?
问题内容: 以下代码可在实时站点上运行,但无法在jsfiddle站点上运行。 谁能告诉我为什么它在jsfiddle上不起作用? 在控制台上,它记录:和。 您将代码作为片段嵌入此处时,可以看到该代码的工作原理: 问题答案: 您定义的函数是在onload函数中定义的,因此在它们被引用之前,因为它们是在该函数中定义的,所以只能在该函数中引用它们。您在HTML中将它们称为全局变量。您有三种选择 a)(最简
问题内容: 我在Windows上有一个基本的webserver hello world应用程序,可用于Windows上的nodejs,它可在localhost上运行。但是,当我从互联网测试它时,它无法连接。我在netgear路由器中设置了端口转发。我是否在这里缺少使我的nodejs服务器对外界可见的步骤? 谢谢。 问题答案: 确保您聆听而不是 是仅对您的计算机可见的专用网络。 侦听所有接口,包括私
问题内容: 我正在尝试在Ubuntu终端上运行javac。但是我得到以下信息: JDK已经安装并运行说 我的jdk安装在/ usr / lib / jvm / java-6-open- jdk中;而且我能够从Eclipse编译并运行Java程序。但是在使用终端时遇到了上述问题。 问题答案: 该二进制(可能其他的Java二进制文件)是/不是您的用户环境变量。有几种解决方法: 添加到用户的环境变量。您
问题内容: 我最近遇到了这个问题: java.util.NoSuchElementException线程“ Thread-4”中的异常java.lang.IllegalStateException:不在FX应用程序线程上;仅在FX应用程序线程上有效。currentThread =线程4 该代码适用于jdk7,但不适用于jdk8,该代码如下所示: 然后我从以下代码中调用此线程: 我要做的就是从其他具
问题内容: 所以我最近一直在C9上使用Node.js,并在一个javascript文件中遇到了这个问题: 这是我的代码: 我更新了所有依赖关系以及Node本身,但仍然遇到此问题。有人知道怎么回事吗? 问题答案: 我面临着同样的问题。正在网上寻找解决方案。事实证明,jsdom自v10以来已更新了一些功能。因此,我想在快速应用程序的Node.js端使用jQuery,并且必须像下面这样进行操作: 从v1