在IDEA中使用Maven中的Lifecycle下的compile命令,发现报错:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project maven-demo: Compilation failure: Compilation failure:
查看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.ran</groupId>
<artifactId>maven-demo</artifactId>
<version>1.0-SNAPSHOT</version>
</project>
原发现缺少properties配置信息;
注意:Java8到java13的版本号分别为1.8或8,1.9,1.10,10,11,12,13
ctrl + shift + s进入设置页面,根据自己的java版本配置相应的properties
加入properties后的pom.xml文件:
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
恭喜!编译成功!
有问题可评论or私信,bye~