无法获取我的java项目来构建org.apache.maven.lifecycle.LifecycleExecutionException:

时间:2017-11-03 13:42:42

标签: java eclipse apache maven

我刚收到一个项目要处理,我正在尝试运行“mvn clean install”以便安装所有插件和依赖项,我收到此错误。有任何想法吗?

  

org.apache.maven.lifecycle.LifecycleExecutionException:无法在项目EHS_ITO_BACKEND上执行目标org.apache.maven.plugins:maven-compiler-plugin:3.1:compile(default-compile):编译失败   此环境中未提供编译器。也许你是在运行JRE而不是JDK?

Environment Variables

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>D</groupId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <finalName>${project.artifactId}</finalName>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.9</source>
          <target>1.9</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
          <failOnMissingWebXml>false</failOnMissingWebXml>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm</artifactId>
            <version>3.3.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-bundle</artifactId>
            <version>1.19</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20140107</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.19</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-core</artifactId>
            <version>1.19</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey.contribs</groupId>
            <artifactId>jersey-multipart</artifactId>
            <version>1.19</version>
        </dependency>
        <dependency>
            <groupId>org.jvnet</groupId>
            <artifactId>mimepull</artifactId>
            <version>1.6</version>
        </dependency>
        <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-servlet</artifactId>
        <version>1.19</version>
    </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.35</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.10-FINAL</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.9</version>
        </dependency>
    </dependencies>
  <artifactId></artifactId>
</project>

1 个答案:

答案 0 :(得分:0)

Maven需要一个JDK来编译你的项目。 Maven使用JAVA_HOME根据此消息找到JDK ......

  

编译失败此环境中未提供编译器。也许你是在运行JRE而不是JDK?

...您的JAVA_HOME不存在或者没有指向JDK。

如果你运行mvn -version它将告诉你它用于Java的用途。你应该看到这样的东西:

Java version: 1.8.0_51, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/jre

如果你没有看到,那么你必须设置你的JAVA_HOME。来自the docs

在Unix上:

export JAVA_HOME=jdk-install-dir

在Windows上

Right click My Computer and select Properties.

On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.6.0_02.