我在构建Neo4j OGM Java项目时遇到了问题。问题是什么?如何解决?
在构建日志中,我有错误:
--- maven-resources-plugin:2.5:resources (default-resources) @ Neo4j-my ---
[debug] execute contextualize
Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
Copying 0 resource
--- maven-compiler-plugin:2.3.2:compile (default-compile) @ Neo4j-my ---
File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
之后我收到编译错误:
-------------------------------------------------------------
COMPILATION ERROR :
-------------------------------------------------------------
neo4jCMS/entity/Person.java:[31,30] error: diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
neo4jCMS/entity/Person.java:[44,28] error: lambda expressions are not supported in -source 1.5
2 errors
-------------------------------------------------------------
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.471s
Finished at: Sun Aug 21 23:49:40 CEST 2016
Final Memory: 7M/150M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project Neo4j-my: Compilation failure: Compilation failure:
neo4jCMS/entity/Person.java:[31,30] error: diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
neo4jCMS/entity/Person.java:[44,28] error: lambda expressions are not supported in -source 1.5
-> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
我的pom.xml文件:https://jpst.it/MsZN
答案 0 :(得分:1)
使用
检查您的maven指向哪个目录Java home:
mvn -version
如果Java home:
指向低于1.7的版本,则相应地设置JAVA_HOME
答案 1 :(得分:1)
您的代码是使用Java 1.8或1.7语法(菱形)编写的,而默认情况下,Maven Compiler插件依赖于Java 1.5。
您只需在构建中指定,如下所示:
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>