IDEA 打包maven工程的小坑
解决打包报错:Perhaps you are running on a JRE rather than a JDK ?
来自:pixpiv 画师( 画师JW )
项目完成之后,开始打包
mvn clean install
出现报错信息如下:
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
解决方案↓
在项目的pom.xml 文件加入maven插件,加入jdk路径:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<fork>true</fork>
<executable>
C:\Program Files\Java\jdk1.8.0_221\bin\javac.exe【填自己的jdk路径】
</executable>
</configuration>
</plugin>
jar包打包成功,命令行中java -jar 【jar包名】。运行成功,正常访问!
另一种方式: 在maven的setting.xml 文件 <profiles> 标签中指定JDK的版本
<profile>
<id>JDK-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>