我有一个使用 JDK 1.5 的项目(由于项目遗留)并且我想使用 ReSTLet。目前,我在 pom.xml 中获取了当前的构建部分:
<build>
<plugins>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>maven-restlet</id>
<name>Restlet repository</name>
<url>http://maven.restlet.com</url>
</repository>
</repositories>
<properties>
<restlet-version>2.2.1</restlet-version>
<spring-version>3.1.1.RELEASE</spring-version>
</properties>
<dependencies>
<dependency>
<groupId>org.restlet.jse</groupId>
<artifactId>org.restlet</artifactId>
<version>${restlet-version}</version>
</dependency>
<dependency>
<groupId>org.restlet.jse</groupId>
<artifactId>org.restlet.ext.jackson</artifactId>
<version>${restlet-version}</version>
</dependency>
</dependencies>
当我通过 Eclipse 运行 mvn install
时,出现以下错误:
[ERROR] src/main/java/com/****/SomeFile.java:[3,-1] cannot access org.restlet.Component
bad class file: ****\.m2\repository\org\restlet\jse\org.restlet\2.2.1\org.restlet-2.2.1.jar(org/restlet/Component.class)
class file has wrong version 50.0, should be 49.0
我知道该错误是因为我尝试使用 Java 5 但使用 Java 6 库来编译项目。如何使用 JDK 1.5 来使用或编译我的依赖项?
最佳答案
您将必须使用旧版本。如果您检查Official Restlet Framework Blog ,在2.2版本的新闻中是这么说的:
We no longer support Java 5 which has been the case since Restlet Framework version 1.0. If you still need to support Java 5 due to other requirements, we encourage you to keep using Restlet Framework 2.1.
关于java - 使用另一个 JDK 编译 Maven 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24649223/