嵌入式Neo4j中的SpatialRepository

时间:2015-03-06 18:48:57

标签: neo4j spring-data-neo4j neo4j-spatial

有人可以回答这个问题。是否可以在嵌入模式下的spring boot应用程序中使用空间存储库?

  @Bean
       public GraphDatabaseService graphDatabaseService() {
          return new GraphDatabaseFactory().newEmbeddedDatabase("neo4j.db");
   }

只需添加

即可
<dependency>
  <groupId>org.neo4j</groupId>
  <artifactId>neo4j-spatial</artifactId>
  <version>0.9</version>
</dependency>

到您的类路径?

我一直收到错误

引起:java.lang.IllegalArgumentException:没有索引提供者&#39; spatial&#39;找到。也许预期的提供程序(或其中一个依赖项)不在类路径上,或者无法加载。     at org.neo4j.kernel.impl.coreapi.IndexManagerImpl.getIndexProvider(IndexManagerImpl.java:91)     at org.neo4j.kernel.impl.coreapi.IndexManagerImpl.findIndexConfig(IndexManagerImpl.java:142)     at org.neo4j.kernel.impl.coreapi.IndexManagerImpl.getOrCreateIndexConfig(IndexManagerImpl.java:209)     at org.neo4j.kernel.impl.coreapi.IndexManagerImpl.getOrCreateNodeIndex(IndexManagerImpl.java:314)     at org.neo4j.kernel.impl.coreapi.IndexManagerImpl.forNodes(IndexManagerImpl.java:302)     在org.springframework.data.neo4j.support.DelegatingGraphDatabase.createIndex(DelegatingGraphDatabase.java:163)     在org.springframework.data.neo4j.support.index.IndexProviderImpl.createIndex(IndexProviderImpl.java:91)     at org.springframework.data.neo4j.support.index.IndexProviderImpl.getIndex(IndexProviderImpl.java:68)     在org.springframework.data.neo4j.support.index.IndexProviderImpl.getIndex(IndexProviderImpl.java:108)     在org.springframework.data.neo4j.support.mapping.EntityIndexCreator $ 2.doWithPersistentProperty(EntityIndexCreator.java:61)     在org.springframework.data.neo4j.support.mapping.EntityIndexCreator $ 2.doWithPersistentProperty(EntityIndexCreator.java:57)     在org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:294)     在org.springframework.data.neo4j.support.mapping.EntityIndexCreator.ensureEntityIndexes(EntityIndexCreator.java:57)     在org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.updateStoredEntityType(Neo4jMappingContext.java:78)     在org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.addPersistentEntity(Neo4jMappingContext.java:71)     在org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.addPersistentEntity(Neo4jMappingContext.java:49)     在org.springframework.data.mapping.context.AbstractMappingContext.addPersistentEntity(AbstractMappingContext.java:257)     在org.springframework.data.mapping.context.AbstractMappingContext.initialize(AbstractMappingContext.java:373)     在org.springframework.data.neo4j.support.mapping.Neo4jMappingContext.initialize(Neo4jMappingContext.java:111)     在org.springframework.data.mapping.context.AbstractMappingContext.afterPropertiesSet(AbstractMappingContext.java:363)     在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625)     在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562)     ... 62更多

2 个答案:

答案 0 :(得分:0)

当然,你可以有弹簧数据neo4j + spring boot。

你可以找到我在这里写的代码:https://github.com/inserpio/neo4art 以及描述我是如何做到的简短帖子:https://inserpio.wordpress.com/2014/09/21/neo4art-moves-to-cloud-foundry-at-springone-2gx-2014/

希望它可以提供帮助!

干杯, 洛伦佐

答案 1 :(得分:0)

在maven pom中使用此存储库

            <repository>
                        <id>neo4j-contrib-releases</id>
                        <url>https://raw.github.com/neo4j-contrib/m2/master/releases</url>
                        <releases>
                            <enabled>true</enabled>
                        </releases>
                        <snapshots>
                            <enabled>false</enabled>
                        </snapshots>
                    </repository>
                    <repository>
                        <id>neo4j-contrib-snapshots</id>
                        <url>https://raw.github.com/neo4j-contrib/m2/master/snapshots</url>
                        <releases>
                            <enabled>false</enabled>
                        </releases>
                        <snapshots>
                            <enabled>true</enabled>
                        </snapshots>
                    </repository>

具有依赖性

                <dependency>
                    <groupId>org.neo4j</groupId>
                    <artifactId>neo4j-spatial</artifactId>
                    <version>0.13-neo4j-2.1.2</version>
                </dependency>