@xtccc
2016-06-25T21:58:19.000000Z
字数 838
阅读 2088
Maven
目录
Problem example:
A.java
public interface A {
void f();
}
B.java
public class B implements A {
@Override
public void f() { return; }
}
用Maven编译B.java时会报错:
@Override is not allowed when implementing interface method
我们需要修改编译的语言级别 —— 用1.7来编译。
方法1:在每个pom.xml文件中增加下面一段
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
方法2:修改~/.m2/settigns.xml文件
<profile>
<id>jdk-1.7</id>
<activation>
<jdk>1.7</jdk>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
</properties>
</profile>