这就是我放在我的POM中。
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
...
<properties>
<java-version>1.6</java-version>
</properties>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
</plugins>
</build>
</project>
一旦我在我的POM中定义了我,请右键单击项目并转到Maven> Update项目。这会将pom中的所有设置应用到eclipse项目中,以确保两者同步。
就JDK而言,我使用最新的JDK,但编译为较低版本。我们目前使用的是JDK 7,但是编译为6.这样可以让您在编译器仍然可以使用与版本6兼容的7个版本中引入的任何优化。