maven打包java11出现 Fatal error compiling: 错误: 无效的目标发行版:11.0 -> [Help 1]解决办法

写mapreduce用maven打成jar包出现Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project mapreduce: Fatal error compiling: 错误: 无效的目标发行版:11.0 -> [Help 1]
[ERROR] 错误, 看到一位大佬的博客才得以解决

原文链接:
https://blog.csdn.net/hike97/article/details/93851132

解决方法:

修改maven的setting.xml文件,向文件中添加以下内容:
 <profile>
	<id>jdk-11</id>
	<activation>
		<activeByDefault>true</activeByDefault>
		<jdk>11</jdk>
	</activation>
	<properties>
		<maven.compiler.source>11</maven.compiler.source>
		<maven.compiler.target>11</maven.compiler.target>
		<maven.compiler.compilerVersion>11</maven.compiler.compilerVersion>
	</properties>
</profile>
点击clean,清除target目录, 重新点击package。让其重新生成jar包.

ok,成功!!再次感谢hike97用户

原文链接:
https://blog.csdn.net/hike97/article/details/93851132

你可能感兴趣的:(Java,maven)