今天在对maven项目打包时候,发生了下面的错误
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.497 s
[INFO] Finished at: 2017-02-23T16:30:37+08:00
[INFO] Final Memory: 10M/150M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project core: Compilation failure: Compilation failure:
[ERROR] /D:/workSpaces/MyEclipse 2016/ecs/core/src/main/java/com/chinatelecom/ecs/core/common/util/HttpClientUtil.java:[59,13] -source 1.5 中不支持 try-with-resources
[ERROR] (请使用 -source 7 或更高版本以启用 try-with-resources)
[ERROR] /D:/workSpaces/MyEclipse 2016/ecs/core/src/main/java/com/chinatelecom/ecs/core/common/util/URLUtil.java:[146,54] -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
于是查看了下资料解决方法如下
Windows——》Preference——》Compiler
在JDK Compliance中设置对应的编译版本,项目中用到的jdk是1.7,但是编译用的是1.8(我的是双环境),然后这里统一都改成项目的1.7引用,重新编译了一下就好了。
未经允许请勿转载:程序喵 » 请使用 -source 7 或更高版本以启用 diamond 运算符