在Ubuntu 12.04,JDK1.7上,Maven构建失败

时间:2014-03-06 10:30:08

标签: java maven ubuntu java-7

我的maven版本在Windows机器上很好,但在Ubuntu上出现编译错误而失败。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project [XXX]: Compilation failure: Compilation failure:
[ERROR] /usr/share/tomcat7/[XXX]:[24,23] error: no suitable constructor found for XXX
[ERROR]
[ERROR] constructor XXX is not applicable
[ERROR] (actual argument Class<XXX> cannot be converted to Class<? extends XXX> by method invocation conversion)
[ERROR] constructor XXX is not applicable
[ERROR] (actual and formal argument lists differ in length)
[ERROR] /usr/share/tomcat7/[XXX]:[36,24] error: no suitable constructor found for XXX)
[ERROR] -> [Help 1]

cat / etc / lsb-release

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04.4 LTS"

java -version

java version "1.7.0_51"
OpenJDK Runtime Environment (IcedTea 2.4.4) (7u51-2.4.4-0ubuntu0.12.04.2)
OpenJDK Client VM (build 24.45-b08, mixed mode, sharing)

mvn -version

Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_51, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-openjdk-i386/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.5.0-46-generic", arch: "i386", family: "unix"

我已经尝试在java 1.6上构建它并将java更改为oracle-7-JDK ...

错误保持不变。

你能帮助我吗?

修改

我已根据provided instructions

安装了Oracle JDK

现在看起来像这样:

java -version

java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) Client VM (build 24.51-b03, mixed mode)

mvn -version

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

构建仍然失败并显示相同的错误消息

1 个答案:

答案 0 :(得分:0)

更新您的pom文件以使用最新的maven-compiler-plugin版本(您使用的是2.0.2极端旧版本)。

<project>
  ...
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.1</version>
          <configuration>
            <!-- put your configurations here -->
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
  ...
</project>