maven install出错:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (d

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project news_search: Compilation failure: Compilation failure: 
[ERROR] /y/ESClientSpringFactory.java:[71,63] -source 1.5 中不支持 lambda 表达式
[ERROR]   (请使用 -source 8 或更高版本以启用 lambda 表达式)
[ERROR] /lasticsearchUtil.java:[180,27] -source 1.5 中不支持 lambda 表达式
[ERROR]   (请使用 -source 8 或更高版本以启用 lambda 表达式)
[ERROR] lasticsearchUtil.java:[339,62] -source 1.5 中不支持 diamond 运算符
[ERROR]   (请使用 -source 7 或更高版本以启用 diamond 运算符)
[ERROR] -> [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/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :news_search

在这里插入图片描述
一看错误,明显是jdk的问题,但是我看了maven,看了jdk。感觉都没问题!
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
还是出错,看来问题还是比较棘手。
网上搜索了一波,找到了一个解决方案。
那就是《在maven的setting.xml中指定jdk版本》,(可以点击进去查看,也可以看下方操作)

打开maven所在的位置,打开conf下的setting.xml,如我的:D:\Path\apache-maven-3.5.4\conf\setting.xml
进行编辑,编辑如下:

	<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>

解决问题!!!

发布了760 篇原创文章 · 获赞 636 · 访问量 11万+

猜你喜欢

转载自blog.csdn.net/qq_41946557/article/details/104292354