java org/codehaus/plexus/archiver/jar/JarArchiver(不支持的major.minor 版本49.0)-Maven 构建错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7530284/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 20:21:14  来源:igfitidea点击:

org/codehaus/plexus/archiver/jar/JarArchiver (Unsupported major.minor version 49.0) - Maven build error

javamaven

提问by Gary

Afternoon all,

下午大家,

I am receiving the above error when trying to build my project. I'm pretty sure this has something to do with Maven's latest update being compiled using Java 1.6 and the project we are trying to build is a 1.4 project. The plugin prior to this worked without problems, so I have added the following to the POM.xml file to try to force the existing plugin to be used.

尝试构建我的项目时收到上述错误。我很确定这与使用 Java 1.6 编译的 Maven 最新更新有关,而我们尝试构建的项目是 1.4 项目。之前的插件没有问题,所以我在 POM.xml 文件中添加了以下内容,以尝试强制使用现有插件。

    <dependency>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-archiver</artifactId>
        <version>1.2</version>
    </dependency>

But it continues to fail.

但它继续失败。

Any help would be much appreciated

任何帮助将非常感激

Thanks

谢谢

回答by user1843654

Try to add the following plugin for maven. It works for me:

尝试为 maven 添加以下插件。这个对我有用:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.3.2</version>
    <configuration>
        <encoding>UTF-8</encoding>
    </configuration>
</plugin>

回答by Tomasz Nurkiewicz

The error you are experiencing means that org/codehaus/plexus/archiver/jar/JarArchiverwas compiled against Java 1.5 whilst you are trying to load using older Java version.

您遇到的错误意味着org/codehaus/plexus/archiver/jar/JarArchiver是在您尝试使用旧 Java 版本加载时针对 Java 1.5 编译的。

1.2 version of plexus-archiverworksunder Java 1.4. However 2.0 requiresJava 1.5. Are you sure you are using 1.2?

1.2 版本在 Java 1.4 下plexus-archiver工作。但是 2.0需要Java 1.5。您确定您使用的是 1.2 吗?

If this is a plugin, it should be defined under <plugins>.

如果这是一个插件,则应在<plugins>.

回答by Eric B.

According to Fred from the m2e-mailing list, this has been fixed with m2eclipse-mavenarchiver 0.17.0. You can install it from http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-mavenarchiver/0.17.0/N/LATEST/

根据 m2e-mailing list 中的 Fred 所说,这个问题已经在 m2eclipse-mavenarchiver 0.17.0 中得到修复。您可以从http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-mavenarchiver/0.17.0/N/LATEST/安装它

Just add the repo as an update site, and then upgrade the mavenarchiver component.

只需将 repo 添加为更新站点,然后升级 mavenarchiver 组件。

回答by user2933809

I was getting this error till I changed my maven-source-plugin version to 2.2.1. I was getting the error with 2.1.1.

在我将 maven-source-plugin 版本更改为 2.2.1 之前,我一直收到此错误。我收到了 2.1.1 的错误。

回答by Leo

Including the 'old' version of a plugin in the pom.xmlis solving part of the problem. you also need to make sure you are using the right jvm to match.

将插件的“旧”版本包含在pom.xml解决部分问题的方法中。您还需要确保使用正确的 jvm 进行匹配。

For a current project i'm working on I had to set JAVA_HOMEto java 1.4 with maven 2.0.8. Problem with maven is that it looks for updates in the local and remote repositories (if there is a remote repository set in the maven settings.xml), than tries use version 2.5 for the 'clean' and 'install' plugins for example causing the major.minor 49.0 error (clean and install plugins version 2.5 are compiled with java 1.5 or greater while I tried to execute them in a java 1.4 environment).

对于我正在处理的当前项目,我必须JAVA_HOME使用 maven 2.0.8设置为 java 1.4。maven 的问题在于它会在本地和远程存储库中查找更新(如果在 maven 中设置了远程存储库settings.xml),而不是尝试使用 2.5 版的“clean”和“install”插件,例如导致major.minor 49.0 错误(我尝试在 java 1.4 环境中执行它们时,使用 java 1.5 或更高版本编译了 2.5 版的清理和安装插件)。

With adding in the plugin snippet in the pom.xmlof the project forcing it to use version 2.2 combined with the old java version on my path:

在项目的插件片段中添加pom.xml强制它在我的路径上使用版本 2.2 和旧的 Java 版本:

(set path=c:\youroldjavadirectory\bin;c:\youroldmavendirectory\bin) everything started working.

( set path=c:\youroldjavadirectory\bin;c:\youroldmavendirectory\bin) 一切都开始工作了。

Check versions of java before running the maven command:

在运行 maven 命令之前检查 java 的版本:

java -version

mvn -v

回答by Mohammad

Use:

利用:

   <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>