参考链接:mvn打包No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK_51CTO博客_mvn打包命令
在执行 yum install -y java-1.8.0-opensdk命令后,使用maven去编译打包,结果报错,
“No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?”
查了很多资料,最后终于找到原因,参考文章首页的链接,默认只安装了jre,没有安装jdk
应该运行
yum -y install java-1.8.0-openjdk-devel #同时安装jdk和jre
或者
yum -y install java-1.8.0-openjdk-1.8.0.272.b10-1.el7_9.x86_64 #只安装jre
yum -y install java-1.8.0-openjdk-devel-1.8.0.272.b10-1.el7_9.x86_64 #安装jdk
然后编辑</etc/profile>,配置环境变量
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.272.b10-1.el7_9.x86_64
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib
并source /etc/profile,使环境变量生效。
安装好JRE和JDK后,用mvn重新编译打包,不再报错: