Eclipse运行maven项目 Java Resource上有个红叉
problems报错为JAX-RS (REST Web Services) 2.0 requires Java 1.6 or newer
试了一些方法,最后用这个方法解决
在pom.xml中添加(或修改)
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
以上为使用jdk1.7,若使用的1.8用
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
原因:jdk版本不一致。
pom.xml中如果没有写此配置,默认是1.5的
解决Eclipse Maven项目JDK版本问题
本文介绍了解决Eclipse中Maven项目因JDK版本不匹配导致的问题的方法。通过在pom.xml文件中指定正确的源码和目标码版本(如1.7或1.8),可以消除JAX-RS 2.0需要Java 1.6或更高版本的错误提示。
1599

被折叠的 条评论
为什么被折叠?



