4

我正在尝试使用 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.xml 中指定的源和目标(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
4

2 回答 2

0

尝试清除本地 Maven 存储库并再次运行构建(也许,也尝试使用“-o”选项运行它)

于 2014-03-14T13:25:26.620 回答
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>
于 2013-01-16T15:42:40.943 回答