1

私の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 configurationsJREタブは に設定されていることを示していますWorkspace default JRE (jre1.8.0_20)

<properties>以下をタグに追加してpom.xmlも何も変わりませんでした。

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

Maven > Update Project構成を試すたびにスキップしませんでした。

プロジェクトは他のどこにも他のエラーを表示していません。

私は何が欠けていますか?

注:他の議論の中で1.7に変更したにもかかわらず、Mavenの「ビルドパスは実行環境J2SE-1.5を指定します」を見ました。

4

2 に答える 2

1

文字通り、「JDK ではなく JRE で実行している可能性がありますか?」と言っているのと同じです。これは、jre ではなく jdk で実行することを意味します。jdk バージョンをダウンロードして構成します。

于 2015-07-18T18:38:10.130 に答える