Maven打包报错:“请使用 -source 7 或更高版本以启用 diamond 运算符”
> [INFO] ------------------------------------------------------------- > [ERROR] COMPILATION ERROR : > [INFO] ------------------------------------------------------------- > -source 1.5 中不支持 diamond 运算符 > (请使用 -source 7 或更高版本以启用 diamond 运算符) > [INFO] 1 error > [INFO] ------------------------------------------------------------- > [INFO] ------------------------------------------------------------------------ > [INFO] BUILD FAILURE > [INFO] ------------------------------------------------------------------------ > [INFO] Total time: 5.976 s > [INFO] Final Memory: 14M/159M > [INFO] ------------------------------------------------------------------------ > [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile > (default-compile) on project storm-samples: Compilation failure > -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] [Help 1]
解决办法:
pom.xml文件内,build> plugins>plugin 内加入以下代码块,其他不改动
<build> <finalName>项目名</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build>
原因:编译版本出现了问题
maven install打包 运行结果如下:
[INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 38.902 s [INFO] Finished at: 2018-12-01T10:30:58+08:00 [INFO] ------------------------------------------------------------------------