【问题标题】:Maven not seeing the compiler on EclipseMaven 在 Eclipse 上看不到编译器
【发布时间】: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 &gt; Run as &gt; Run configurations上打开的窗口, JRE 选项卡显示它设置为 Workspace default JRE (jre1.8.0_20)

将以下内容添加到pom.xml 中的&lt;properties&gt; 标记并没有改变任何内容。

 <maven.compiler.source>1.8</maven.compiler.source>
 <maven.compiler.target>1.8</maven.compiler.target>

我每次尝试配置时都没有跳过Maven &gt; 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


    【解决方案1】:

    它实际上是在对您说“也许您是在 JRE 而不是 JDK 上运行?”,这意味着 - 不要在 jre 上运行,而是在 jdk 上运行。下载jdk版本并配置好,祝你好运

    【讨论】:

      【解决方案2】:

      Window → Preferences → Java → Installed JREs. 已修复。它被设置为 JRE——将它设置为 JDK——我的JAVA_HOME 正在显示的那个。

      Eclipse/Maven error: "No compiler is provided in this environment" 帮助了它。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-09-18
        • 2019-01-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-04-13
        • 1970-01-01
        相关资源
        最近更新 更多