Ami*_*nul 23 java intellij-idea maven maven-compiler-plugin spring-boot
我试图从Spring-boot开始,在Intellij中使用Maven请帮助我我收到错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:compile (default-compile) on project spring-rest: Fatal error compiling: invalid flag: --release -> [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
Process finished with exit code 1
Run Code Online (Sandbox Code Playgroud)
我的pom.xml是:
<?xml version="1.0" encoding="UTF-8"?> <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>com.example</groupId>
<artifactId>spring-rest</artifactId>
<version>3.1.3.RELEASE</version>
<packaging>war</packaging>
<name>spring-rest</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>8</release>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
Mat*_*ldi 28
在您的pom.xml文件中,只需<release>8</release>从maven-compiler-plugin配置中删除标记 :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<verbose>true</verbose>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
小智 20
我也遇到这个问题,检查你的JAVA_HOME环境变量。我将release的值设置为11,因为我使用的是JAVA 11。我的系统JAVA_HOME设置为java 8,将JAVA_HOME用户环境变量添加到java 11路径后,这个问题得到了解决。
izy*_*izy 15
打开终端检查 Maven 是否使用正确的 Java 版本
跑步:mvn -v
如果您看到旧的 Java 版本,则可能是问题所在。
在 Linux 上,我建议删除 Maven,例如使用 Fedora 包管理器dnf remove maven或检查 Maven 的 PATH。
从这里下载一个: https: //maven.apache.org/download.cgi
解压下载到您的主路径,例如~/maven.
添加/编辑~/maven/bin到您的路径
重新应用.bash_profile(或重新登录)
跑步mvn -v
现在您应该在输出中看到正确的 Java 版本
| 归档时间: |
|
| 查看次数: |
23341 次 |
| 最近记录: |