maven编译时始终出现以下提示:
error: generics are not supported in -source 1.3
-source 1.3 中不支持泛型(请使用 -source 5 或更高版本以启用泛型)
error: annotation are not supported in -source 1.3
-source 1.3 中不支持注解(请使用 -source 5 或更高版本以启用注释)
而用mvn -v查看结果:
Apache Maven 3.0.5
Maven home: /usr/share/maven
Java version: 1.7.0_60, vendor: Oracle Corporation
Java home: /usr/lib/jvm/jdk1.7.0_60/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.13.0-45-generic", arch: "amd64", family: "unix"
显然与所配置的JDK无关。最终解决办法:
在项目的pom.xml中,添加:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
问题解决了,可是紧接着编译,发现又产生新的错误提示:
error: multi-catch statement is not supported in -source 1.5
-source 1.5 中不支持多catch语句块
于是,我狠了狠心,将maven的编译插件直接提高到1.7,修改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>
OK,KO!
参考链接:Compiler插件配置