neo4j 學習筆記


1.參考 https://blog.csdn.net/appleyk/article/category/7408344 系列文章 (不支持 spring boo 2.0 以下的,入門可做參考)

2.底層驅動 https://github.com/neo4j/neo4j-ogm 

3.數據庫訪問  https://neo4j.com/developer/spring-data-neo4j/ (支持 spring boo 2.0)

 

常用命令

//級聯刪除所有節點和關系
Match(n) detach delete n;
//刪除所有階段
Match(n) delete n;
//查詢所有coder類型節點信息
Match(n:coder) return n;

 

從 1.0 升級到 2.0 踩坑

1.招不到  org.neo4j:neo4j-ogm-http-driver  這個包,在 1.0 中 會自動安裝該包,2.0 不會自動安裝,該包功能具體參考上面的第二點,底層驅動

2. 1.0 中 Repository 繼承 GraphRepository ,2.0 中取消掉了,改成了 Neo4jRepository ,具體使用請看上面第三點。

3.遇到奇奇怪怪的報錯,就添加這段代碼。

@Value("${spring.data.neo4j.uri}")
private String databaseUrl;

@Value("${spring.data.neo4j.username}")
private String userName;

@Value("${spring.data.neo4j.password}")
private String password;

@Bean
public SessionFactory sessionFactory() {
    Configuration configuration = new Configuration.Builder()
            .uri(databaseUrl)
            .credentials(userName, password)
            .build();
    return new SessionFactory(configuration, "com.xxx.xx.xx.neo4jnode"); //com.xxx.xx.xx.neo4jnode  neo4j節點的實體類的包
}

 4 org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'transactionManager' available: No matching PlatformTransactionManager bean found for qualifier 'transactionManager' - neither qualifier match nor bean name match!

原因是沒有配置  neo4j 的transactionManager

 
         
@Bean
public Neo4jTransactionManager transactionManager() throws Exception {
return new Neo4jTransactionManager(sessionFactory());
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM