【发布时间】:2015-10-08 06:16:31
【问题描述】:
我的 Maven 项目没有看到编译器——它是 Eclipse 上的 JavaSE-1.8。编译器在 Eclipse 的其他任何地方都运行良好。
我不断收到的错误是:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project DNM: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
我的pom.xml如下:
<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>AxyMVN</groupId>
<artifactId>DNM</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>DNM</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
项目上编译器的配置似乎很好:
在项目浏览器窗口中,项目上的
JRE System Library显示它设置为JavaSE-1.8。项目的
Java Compiler属性设置为Use compliance from execution environment 'JavaSE-1.8' on the Java Build Path。在项目的
Run Configurations窗口中,在Right-click > Run as > Run configurations上打开的窗口,JRE选项卡显示它设置为Workspace default JRE (jre1.8.0_20)。
将以下内容添加到pom.xml 中的<properties> 标记并没有改变任何内容。
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
我每次尝试配置时都没有跳过Maven > Update Project。
该项目在其他任何地方都没有显示任何其他错误。
我错过了什么?
注意:我在其他一些讨论中看到了Maven "build path specifies execution environment J2SE-1.5", even though I changed it to 1.7。
【问题讨论】:
标签: java eclipse maven maven-compiler-plugin