maven 构建编译失败:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile)

第一种办法是:
设置Install JRE时候选中JDK的目录,因为jdk下面也有一个jre。
为什么这个可以是因为maven的eclipse插件一些功能需要使用JDK,所以使用jdk目录可以解决这个问题。

实践后是可以解决问题的。

第二种方法比较繁琐:

在项目的pom.xml文件中:该代码放于project节点下:
pom中如下配置maven编译插件:

<build>
<plugins>
<plugin>
    <groupId>org.apache.maven.pluginsgroupId>
    <artifactId>maven-compiler-pluginartifactId>
    <version>3.1version>
    <configuration>
        <verbose>trueverbose>
        <fork>truefork>
        <executable>${JAVA8_HOME}/bin/javacexecutable>
    configuration>
plugin>
plugins>
build>

上面JAV A8_HOME在%maven安装目录%/conf/settings.xml中profiles节点下新增如下;

<profile>
      <id>custom-compilerid>
      <properties>
        <JAVA8_HOME>C:\fastDev\Java\jdk1.8.0_91JAVA8_HOME>
      properties>
    profile>
  profiles>

配置后还要激活上面的配置,在settings节点下配置。

<activeProfiles>
        <activeProfile>custom-compileractiveProfile>
activeProfiles>

上面两种方法都是可以解决这个问题。

参考:
Maven构建失败
针对Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1的解决方案

你可能感兴趣的:(经验分享,java-8学习记录,maven)