2013-09-24 84 views
2

我目前正在使用嵌入式neo4j運行我的webapp。現在我想更改爲獨立的neo4j服務器。 在研究與獨立服務器的工作時,我偶然發現了spring-data-neo4j。與spring-data-jpa一起工作並記住連接到db有多容易,我開始尋找一個很好的教程,介紹如何使用spring-data-neo4j。如何用獨立的neo4j服務器配置spring-data-neo4j?

spring-data-neo4j-rest似乎是可能的。這留下了如何使用java配置來配置它的問題,而不是使用xml。

spring data neo4j doc不提供任何有關的信息。

回答

10

你只需要實現一個配置類,用你的URL創建一個SpringRestGraphDatabase

喜歡的東西:

@Configuration 
@EnableNeo4jRepositories(basePackages = "org.springframework.data.neo4j.repository") 
static class Config extends Neo4jConfiguration { 

    @Bean 
    public GraphDatabaseService graphDatabaseService() { 
     return new SpringRestGraphDatabase("http://localhost:7474/db/data/"); 
    } 
} 
相關問題