Maven不使用特定的源和目标设置

时间:2013-01-16 15:40:08

标签: java maven

我正在尝试使用maven构建一个java项目。在项目根目录的pom.xml文件中,我有以下几行:

  <plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <configuration>
    <source>1.6</source>                                                                             
    <target>1.6</target>
    <debug>true</debug>
    <encoding>UTF-8</encoding>
  </configuration>
</plugin>

但是当我尝试使用mvn -DskipTests -U install构建时,我得到以下error: static import declarations are not supported in -source 1.3

maven没有使用我在pom中指定的源和目标(1.6)。

java -version
java version "1.7.0_11"
Java(TM) SE Runtime Environment (build 1.7.0_11-b21)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)

mvn --version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_11, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.5.0-21-generic", arch: "amd64", family: "unix"

uname -a
Linux ubuntu 3.5.0-21-generic #32-Ubuntu SMP Tue Dec 11 18:51:59 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

maven是否还有其他地方可以从中获取默认的源和目标设置?为什么不使用pom中的设置?

在调试模式下运行maven时,以下是一段错误消息:

 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project LeaderLines: Compilation failure
 [ERROR] /path/geoserver-2.2/geotools-plugin/LeaderLines/src/org/geotools/filter/function/FilterFunction_leaderLine.java:[22,7] error: static import declarations are not supported in -source 1.3

 [ERROR] -> [Help 1]                                                                                
 org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins: maven-compiler-plugin:2.0.2:compile (default-compile) on project LeaderLines: Compilation failure
 /path/geoserver-2.2/geotools-plugin/LeaderLines/src/org/geotools/filter/function/FilterFunction_leaderLine.java:[22,7] error: static import declarations are not supported in -source 1.3

2 个答案:

答案 0 :(得分:0)

尝试使用以下属性设置源级别和源编码:

<properties>
    <maven.compiler.source>1.6</maven.compiler.source>
    <maven.compiler.target>1.6</maven.compiler.target>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

答案 1 :(得分:0)

尝试清除您当地的Maven仓库并再次运行您的构建(也许,尝试使用'-o'选项运行它)