简体   繁体   English

Maven try-with-resources错误中的neo4j EmbeddedNeo4j.java

[英]neo4j EmbeddedNeo4j.java in maven try-with-resources error

I'm attempting to run the first example in the Neo4j Manual chapter 32 on using Neo4j embedded in Java applications, the file is EmbeddedNeo4j.java , I'm using maven, with the proper Neo4j dependency. 我正在尝试运行Neo4j手册第32章中有关使用Java应用程序中嵌入的Neo4j的第一个示例,该文件是EmbeddedNeo4j.java ,我正在使用具有适当Neo4j依赖项的maven。 I'm getting a compilation error that seems to indicate I'm using Java 1.5, but everything I see tells me I'm using Java 1.7. 我收到一个似乎表明我正在使用Java 1.5的编译错误,但是我看到的一切都告诉我我正在使用Java 1.7。

Here's the error: 这是错误:

EmbeddedNeo4j.java:[71,12] error: try-with-resources is not supported in -source 1.5

Here's why I think Maven should be using Java 1.7: 这就是我认为Maven应该使用Java 1.7的原因:

[root@cerif t02]# mvn -version [root @ cerif t02]#mvn -version
Apache Maven 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 13:51:28+0000) Apache Maven 3.0.5(r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 13:51:28 + 0000)
Maven home: /opt/apache-maven-3.0.5 Maven主页:/opt/apache-maven-3.0.5
Java version: 1.7.0_21, vendor: Oracle Corporation Java版本:1.7.0_21,供应商:Oracle Corporation
Java home: /usr/java/jdk1.7.0_21/jre Java主页:/usr/java/jdk1.7.0_21/jre
Default locale: en_US, platform encoding: UTF-8 默认语言环境:en_US,平台编码:UTF-8
OS name: "linux", version: "3.9.3-x86-linode52", arch: "i386", family: "unix" 操作系统名称:“ linux”,版本:“ 3.9.3-x86-linode52”,拱门:“ i386”,家族:“ unix”
[root@cerif t02]# [root @ cerif t02]#

Any advice on tracking down why I'm getting this error? 关于追踪为什么我会收到此错误的任何建议?

Have you told Maven to use Java 1.7 compatibility mode? 您是否已告诉Maven使用Java 1.7兼容模式?

If not, try adding this to your pom.xml: 如果没有,请尝试将其添加到您的pom.xml中:

<build>
  <plugins>
     <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
           <source>1.7</source>
           <target>1.7</target>
        </configuration>
     </plugin>
  </plugins>
</build>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM