我是neo4j的新手并试图将.osm数据导入我的embeddedDatabase,但它不起作用。我搜索了一些示例代码,最后我得到了这个代码,我通过尝试理解TestOSMImport.java
private void importOSM(){
OSMImporter importer = new OSMImporter("map2.osm");
importer.setCharset(Charset.forName("UTF-8"));
try{
System.out.println("Bis hier");
GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);
importer.importFile(db, "map2.osm",false,5000,true);
System.out.println("start____ReIndex!");
importer.reIndex(db,10000);
db.shutdown();
}catch(Exception e){
System.out.println("__________Import Error!! "+e.getMessage());
e.printStackTrace();
}
}
代码正在启动reIndex方法,然后出现此错误
Re-indexing with GraphDatabaseService: EmbeddedGraphDatabase [neo4j-community-1.9.4\data\graph.db] (class: class org.neo4j.kernel.EmbeddedGraphDatabase)
Exception in thread "main" java.lang.NoSuchMethodError: org.neo4j.graphdb.Transaction.close()V
at org.neo4j.gis.spatial.SpatialDatabaseService.getOrCreateRootFrom(SpatialDatabaseService.java:75)
at org.neo4j.gis.spatial.SpatialDatabaseService.getSpatialRoot(SpatialDatabaseService.java:80)
at org.neo4j.gis.spatial.SpatialDatabaseService.getLayer(SpatialDatabaseService.java:102)
at org.neo4j.gis.spatial.SpatialDatabaseService.getOrCreateLayer(SpatialDatabaseService.java:196)
at org.neo4j.gis.spatial.SpatialDatabaseService.getOrCreateLayer(SpatialDatabaseService.java:208)
at org.neo4j.gis.spatial.osm.OSMImporter.reIndex(OSMImporter.java:264)
at foo.App.importOSM(App.java:67)
at foo.App.main(App.java:82)
Suppressed: java.lang.NoSuchMethodError: org.neo4j.graphdb.Transaction.close()V
at org.neo4j.gis.spatial.SpatialDatabaseService.getLayer(SpatialDatabaseService.java:113)
... 5 more
Suppressed: java.lang.NoSuchMethodError: org.neo4j.graphdb.Transaction.close()V
at org.neo4j.gis.spatial.SpatialDatabaseService.getOrCreateLayer(SpatialDatabaseService.java:204)
... 4 more
有人可以帮助我找到解决方案吗?
我将maven用于neo4j和-spatial
感谢您使用neo4j 1.9.4的回复 这是我的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>1</version>
<!-- Inferring Ranking On Networks by Inquiry Distance -->
<name>neo4j</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-core</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-spatial</artifactId>
<version>0.12-neo4j-2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.vividsolutions</groupId>
<artifactId>jts</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>com.tinkerpop.gremlin</groupId>
<artifactId>gremlin-groovy</artifactId>
<version>2.4.0</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-kernel</artifactId>
<version>1.7</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>mvn</id>
<url>http://repo.maven.apache.org</url>
</repository>
<repository>
<id>mvnrepository</id>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>neo4j-release-repository</id>
<name>Neo4j Maven 2 release repository</name>
<url>http://m2.neo4j.org/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>neo4j-snapshot-repository</id>
<name>Neo4j Maven 2 snapshot repository</name>
<url>http://m2.neo4j.org/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
答案 0 :(得分:1)
您必须使用为您正在使用的Neo4j版本构建的neo4-spatial
版本。尝试更改
<version>0.12-neo4j-2.0.0-SNAPSHOT</version>
到
<version>0.11-neo4j-1.9</version>