在项目的pom.xml的<build></build>标签中加入:
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
- </plugins>
保存,项目构建完成后在项目文件夹上点右键,选择Maven->Update Project Configuration,问题解决。
StackOverFlow问题答案:
Maven projects come with a bunch of plugins applied implicitly to the build. One of them being the maven-compiler-plugin
. Unfortunately the Java version for the plugin defaults to 1.5. Most Maven project you see will override the Java version simply by declaring the plugin (in your pom.xml file) and configuring the Java version
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
Eclipse (with m2e plugin) will set the compiler compliance level to the setting in the plugin. You can view this by going to
链接:http://stackoverflow.com/questions/30082476/eclipse-jax-rs-rest-web-services-2-0-requires-java-1-6-or-newerRight click on the project -> properties -> Java Compiler -> Look at compliance level