未能执行目标org.apache.maven.plugins:maven编译器plugin:3.1:compile in Spring

未能执行目标org.apache.maven.plugins:maven编译器plugin:3.1:compile in Spring,spring,maven,Spring,Maven,我正在STS的Spring安全项目中工作。我试图建立我的项目,但我得到以下例外。 错误日志 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 13.2

我正在STS的Spring安全项目中工作。我试图建立我的项目,但我得到以下例外。 错误日志

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.288 s
[INFO] Finished at: 2015-11-27T09:41:59+05:30
[INFO] Final Memory: 21M/227M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project spring-data-rest-security: Fatal error compiling: invalid target release: 1.8 -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
我的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>

    <artifactId>spring-data-rest-security</artifactId>

    <name>Spring Data REST - Security Example</name>

    <parent>
        <groupId>org.springframework.data.examples</groupId>
        <artifactId>spring-data-rest-examples</artifactId>
        <version>1.0.0.BUILD-SNAPSHOT</version>
    </parent>

    <properties>
        <spring-security.version>4.0.2.RELEASE</spring-security.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>

        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
        </dependency>

    </dependencies>

</project>

4.0.0
spring数据rest安全性
Spring数据REST-安全示例
org.springframework.data.examples
spring数据rest示例
1.0.0.1构建快照
4.0.2.1发布
org.springframework.boot
spring引导启动器数据jpa
org.springframework.boot
弹簧启动安全
org.hsqldb
hsqldb

我读过类似问题的答案,但似乎都不起作用。请帮助我。

在命令行
C:\mvn>echo%JAVA\u HOME%
中执行此操作。如果输出类似于
C:\Program Files\JAVA\jdk1.X…
其中X不是数字8,那么您试图使用错误的jdk版本构建它


安装JDK1.8并确保您的%JAVA_主页指向该版本,或者将目标版本放到1.X。

这样做没有帮助。我也有同样的问题,我的%JAVA_HOME%指向jdk1.8.0_45。我还拥有IntelliJ“项目设置>>构建、执行、部署>>模块编译器版本”和“项目结构>>模块>>源代码”中的java版本1.8语言版本8。然而,这并没有解决我的问题

根据apache资源,Maven 3.0之后的默认源代码设置似乎是1.5,需要使用pom.xml进行手动覆盖。我在pom.xml中明确提供了1.8版本的源代码和目标版本,它确实解决了我的问题

 <plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.3</version>
  <configuration>
     <source>1.8</source>
     <target>1.8</target>
  </configuration>
 </plugin>

org.apache.maven.plugins
maven编译器插件
3.3
1.8
1.8

您是否使用Java 8编译器进行编译?