2

Hello i'm new in neo4j and i would like to use OSM + Neo4j Spatial. I have a maven project and my Neo4j version is 2.3.0-M01

I have a simple code just for importing an OSM file but it displays some errors in the import files: GraphDatabaseService, EmbeddedGraphDatabase and BatchInserter.

package testOSM;

import java.nio.charset.Charset;
import org.neo4j.gis.spatial.osm.OSMImporter;

import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.kernel.EmbeddedGraphDatabase;
import org.neo4j.kernel.impl.batchinsert.BatchInserter;

public class TestOsm {

    private static final String DB_PATH = "/community/data/graph.db";

    public static void main(final String[] args){

        OSMImporter importer = new OSMImporter("clz_map.osm");
        importer.setCharset(Charset.forName("UTF-8"));
        BatchInserter batchInserter = BatchInserter.inserter(DB_PATH);

        try{
            importer.importFile(batchInserter, "clz_map.osm", false);
            GraphDatabaseService db = new EmbeddedGraphDatabase(DB_PATH);
            importer.reIndex(db);
            db.shutdown();
            }

        catch(Exception e){
            System.out.println(e.getMessage());
            }

        batchInserter.shutdown();    
    }  
}

May be my problem is with the versions, because i'm using Neo4j 2.3-M01, but i don't know exactly how should i set the versions e.g. here

<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-graph-collections</artifactId>
    <version>0.7.1-neo4j-2.0.2-SNAPSHOT</version>
    <type>jar</type>
</dependency>

My pom.xml is based on https://github.com/neo4j-contrib/spatial/blob/master/pom.xml

Plus:

 <repository>
    <id>neo4j</id>
    <url>http://m2.neo4j.org/content/repositories/releases/</url>
    <releases>
    <enabled>true</enabled>
    </releases>
  </repository>
<dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j</artifactId>
    <version>2.3.0-M01</version>
    <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>org.neo4j</groupId>
    <artifactId>neo4j-kernel</artifactId>
    <version>2.3.0-M01</version>
 </dependency>

You can have a look into my git repository https://github.com/amhg/OSM

Thank you in advance!

4

3 回答 3

1

我查看了您的 pom.xml,看起来您从 Neo4j Spatial 复制了 pom.xml。这不是你想要的。

由于您正在尝试编写一个使用 Neo4j Spatial 的应用程序,因此您应该有一个新的 pom 并将 neo4j-spatial 称为依赖项,而不是与 neo4j-spatial pom 有任何相似之处的 pom。自述文件中有一节描述了如何将 neo4j-spatial 作为依赖项添加到您自己的 pom.xml 中。

因此,我建议您执行以下操作:

于 2015-07-29T19:42:15.480 回答
1

自上次发布版本以来,API 发生了变化。查看https://github.com/neo4j-contrib/spatial/blob/master/pom.xml#L4,如果您自己构建该项目,您似乎可以使用 Neo4j 2.2.3

mvn install

然后将版本 0.15-neo4j-2.2.3 的空间插件从本地 mvn 存储库包含到您的 pom.xml 中。

于 2015-07-29T07:47:03.623 回答
1

对于遇到此问题的其他人,这里是如何做到的:https ://github.com/maxdemarzi/OSM

请注意 2.2.x 和 2.3 之间的细微差别(目前在 M2 上为 7/30)。只需要正确的依赖项。

于 2015-07-30T15:15:47.587 回答