首页 > 解决方案 > Maven 执行目标编译失败

问题描述

我正在mvn compile从终端在 Solaris 服务器上编译一个简单的 maven 应用程序,我收到以下错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project maven-demo: Compilation failure -> [Help 1]

这是我的 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>MavenTest</groupId>
  <artifactId>maven-demo</artifactId>
  <version>0.0.1-SNAPSHOT</version>

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

    <build>
        <plugins>
            <plugin> 
                 <artifactId>maven-compiler-plugin</artifactId> 
                 <version>3.6.1</version> 
                 <configuration>         
                     <fork>true</fork>
                     <source>1.8</source>
                     <target>1.8</target>
                     <executable>/usr/jdk/instances/jdk1.8.0</executable> 
                 </configuration> 
            </plugin> 
        </plugins>
    </build>

    </project>

标签: mavenpom.xmlmaven-compiler-plugin

解决方案


<executable>的不是javac。您需要指定完整路径,而不是目录。


推荐阅读