首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

springboot集成neo4j,使用继承Neo4jRepository的方式来实现对数据的操作

后端 77.76KB 28 需要积分: 1
立即下载

资源介绍:

springboot集成neo4j,这里使用Spring DATA Neo4j模块来实现。 主要使用以下​ Spring Framework ​注释来开发此应用程序: S.No. Spring DATA Neo4j注解 用法 1 @GraphEntity 定义域类​Neo4j Entity​ 2 @GraphID 定义节点或关系​id​ 3 @GraphProperty 定义节点或关系属性 Spring DATA Neo4j模块的附加功能: 支持Neo4j属性图模块 支持Neo4j Lucence索引 支持Neo4j CQL 支持Neo4jTemplate
package com.neo4j.controller; import com.neo4j.domain.Movie; import com.neo4j.domain.Person; import com.neo4j.domain.Roles; import com.neo4j.domain.SystemEntity; import com.neo4j.repository.MovieRepository; import com.neo4j.repository.PersonRepository; import com.neo4j.repository.SystemRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import java.util.Collections; import java.util.List; @Controller @RequestMapping("/neo4j") public class Neo4jController { @Autowired private MovieRepository movieRepository; @Autowired private PersonRepository personRepository; @Autowired private SystemRepository systemRepository; /** * 使用repository操作图数据 * * @return */ @GetMapping("/testByRepository") @ResponseBody public List testByRepository() { // 删除所有节点和关系(删除节点会响应删除关联关系),避免后续创建节点重复影响 movieRepository.deleteAll(); personRepository.deleteAll(); // 创建节点 Movie movie = new Movie("流浪地球", "是由中国电影股份有限公司、北京京西文化旅游股份有限公司、郭帆文化传媒(北京)有限公司、北京登峰国际文化传播有限公司联合出品,由郭帆执导,吴京特别出演、屈楚萧、赵今麦、李光洁、吴孟达等领衔主演的科幻冒险电影"); // 添加关系 movie.getActorsAndRoles().add(new Roles(new Person(1994, "刘启"), Collections.singletonList("初级驾驶员"))); movie.getActorsAndRoles().add(new Roles(new Person(2002, "刘培强"), Collections.singletonList("中国航天员"))); movie.getActorsAndRoles().add(new Roles(new Person(1952, "韩子昂"), Collections.singletonList("高级驾驶员"))); movie.getActorsAndRoles().add(new Roles(new Person(2002, "韩朵朵"), Collections.singletonList("初中生"))); movie.getActorsAndRoles().add(new Roles(new Person(1981, "王磊"), Collections.singletonList("救援队队长"))); movie.getActorsAndRoles().add(new Roles(new Person(1991, "李一一"), Collections.singletonList("技术观察员"))); movie.getActorsAndRoles().add(new Roles(new Person(1974, "何连科"), Collections.singletonList("救援队队员"))); movie.getActorsAndRoles().add(new Roles(new Person(1991, "Tim"), Collections.singletonList("中美混血儿"))); movie.getDirectors().add(new Person(1974, "吴京")); // 存入图数据库持久化 movieRepository.save(movie); // 查询 Person person = personRepository.findPersonEntityByName("刘启"); System.out.println(person); Movie movie1 = movieRepository.findMovieByTitle("流浪地球"); System.out.println(movie1); Movie movie2 = movieRepository.findMovieById(movie.getId()); System.out.println(movie2); // 注意:repository的save方法【对应的实体若id一致】则为修改,否则为新建。 person.setBorn(1997); personRepository.save(person); person = personRepository.findPersonEntityByName("刘启"); List all = personRepository.findAll(); return all; } /** * 新增SystemEntity节点 */ @GetMapping("/addSystemNode") public void addSystemNode() { systemRepository.deleteAll(); SystemEntity systemEntity = new SystemEntity(); systemEntity.setName("系统A"); // 26 systemRepository.save(systemEntity); System.out.println("系统A" + "----------" + systemEntity.getId()); SystemEntity systemEntity1 = new SystemEntity(); systemEntity1.setName("系统B");// 27 systemRepository.save(systemEntity1); System.out.println("系统B" + "----------" + systemEntity1.getId()); SystemEntity systemEntity2 = new SystemEntity(); systemEntity2.setName("系统C");// 28 systemRepository.save(systemEntity2); System.out.println("系统C" + "----------" + systemEntity2.getId()); SystemEntity systemEntity3 = new SystemEntity(); systemEntity3.setName("系统D");// 29 systemRepository.save(systemEntity3); System.out.println("系统D" + "----------" + systemEntity3.getId()); SystemEntity systemEntity4 = new SystemEntity(); systemEntity4.setName("系统E");// 30 systemRepository.save(systemEntity4); System.out.println("系统E" + "----------" + systemEntity4.getId()); SystemEntity systemEntity5 = new SystemEntity(); systemEntity5.setName("系统F");// 31 systemRepository.save(systemEntity5); System.out.println("系统F" + "----------" + systemEntity5.getId()); } @GetMapping("/addInvokeRelation") public void addInvokeRelation() { systemRepository.addInvokeRelation(26L, 27L); systemRepository.addInvokeRelation(26L, 28L); systemRepository.addInvokeRelation(29L, 26L); systemRepository.addInvokeRelation(29L, 28L); systemRepository.addInvokeRelation(29L, 28L); } @GetMapping("/addConsumeRelation") public void addConsumeRelation() { systemRepository.addConsumeRelation(30L, 31L); systemRepository.addConsumeRelation(29L, 30L); } // 分页查询 @GetMapping("/pageListSystem") @ResponseBody public List pageListSystem(String name) { PageRequest pageRequest = PageRequest.of(0, 4, Sort.by(Sort.Direction.DESC, "name")); Page page = systemRepository.findByName(name, pageRequest); List list = page.getContent(); list.forEach(System.out::println); return list; } /** * 删除指定节点直接的关系 DELETE ,, * * @return */ @DeleteMapping("/deleteConsumeRelation") @ResponseBody public String deleteConsumeRelation2() { try { Long from = 28L, to = 29L; systemRepository.deleteConsumeRelation(from, to); } catch (Exception e) { e.printStackTrace(); return "删除关系失败"; } return "删除关系成功"; } @GetMapping("/findSystemById") @ResponseBody public SystemEntity findSystemById(@RequestParam("id") Long id) { SystemEntity systemEntity = systemRepository.findSystemById(id); return systemEntity; } @GetMapping("/getAllSystemNode") @ResponseBody public List getAllSystemNode() { List all = systemRepository.findAll(); return all; } }

资源文件列表:

springboot-neo4j-demo.zip 大约有152个文件
  1. springboot-neo4j-demo/
  2. springboot-neo4j-demo/.gitignore 395B
  3. springboot-neo4j-demo/.idea/
  4. springboot-neo4j-demo/.idea/.gitignore 184B
  5. springboot-neo4j-demo/.idea/codeStyles/
  6. springboot-neo4j-demo/.idea/codeStyles/Project.xml 269B
  7. springboot-neo4j-demo/.idea/codeStyles/codeStyleConfig.xml 153B
  8. springboot-neo4j-demo/.idea/compiler.xml 699B
  9. springboot-neo4j-demo/.idea/encodings.xml 267B
  10. springboot-neo4j-demo/.idea/inspectionProfiles/
  11. springboot-neo4j-demo/.idea/inspectionProfiles/Project_Default.xml 1.41KB
  12. springboot-neo4j-demo/.idea/jarRepositories.xml 879B
  13. springboot-neo4j-demo/.idea/libraries/
  14. springboot-neo4j-demo/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_2_3.xml 619B
  15. springboot-neo4j-demo/.idea/libraries/Maven__ch_qos_logback_logback_core_1_2_3.xml 598B
  16. springboot-neo4j-demo/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_11_4.xml 702B
  17. springboot-neo4j-demo/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_11_4.xml 653B
  18. springboot-neo4j-demo/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_11_4.xml 681B
  19. springboot-neo4j-demo/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_11_4.xml 732B
  20. springboot-neo4j-demo/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_11_4.xml 746B
  21. springboot-neo4j-demo/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_11_4.xml 787B
  22. springboot-neo4j-demo/.idea/libraries/Maven__com_jayway_jsonpath_json_path_2_4_0.xml 597B
  23. springboot-neo4j-demo/.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml 751B
  24. springboot-neo4j-demo/.idea/libraries/Maven__io_github_classgraph_classgraph_4_8_151.xml 622B
  25. springboot-neo4j-demo/.idea/libraries/Maven__jakarta_activation_jakarta_activation_api_1_2_2.xml 684B
  26. springboot-neo4j-demo/.idea/libraries/Maven__jakarta_annotation_jakarta_annotation_api_1_3_5.xml 684B
  27. springboot-neo4j-demo/.idea/libraries/Maven__jakarta_xml_bind_jakarta_xml_bind_api_2_3_3.xml 662B
  28. springboot-neo4j-demo/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_10_19.xml 594B
  29. springboot-neo4j-demo/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_10_19.xml 636B
  30. springboot-neo4j-demo/.idea/libraries/Maven__net_minidev_accessors_smart_1_2.xml 593B
  31. springboot-neo4j-demo/.idea/libraries/Maven__net_minidev_json_smart_2_3.xml 558B
  32. springboot-neo4j-demo/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_13_3.xml 624B
  33. springboot-neo4j-demo/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_13_3.xml 659B
  34. springboot-neo4j-demo/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_9_0_41.xml 676B
  35. springboot-neo4j-demo/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_9_0_41.xml 711B
  36. springboot-neo4j-demo/.idea/libraries/Maven__org_apiguardian_apiguardian_api_1_1_0.xml 623B
  37. springboot-neo4j-demo/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_9_6.xml 593B
  38. springboot-neo4j-demo/.idea/libraries/Maven__org_assertj_assertj_core_3_18_1.xml 593B
  39. springboot-neo4j-demo/.idea/libraries/Maven__org_glassfish_jakarta_el_3_0_3.xml 580B
  40. springboot-neo4j-demo/.idea/libraries/Maven__org_hamcrest_hamcrest_2_2.xml 548B
  41. springboot-neo4j-demo/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_5_7_0.xml 617B
  42. springboot-neo4j-demo/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_api_5_7_0.xml 645B
  43. springboot-neo4j-demo/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_engine_5_7_0.xml 666B
  44. springboot-neo4j-demo/.idea/libraries/Maven__org_junit_jupiter_junit_jupiter_params_5_7_0.xml 666B
  45. springboot-neo4j-demo/.idea/libraries/Maven__org_junit_platform_junit_platform_commons_1_7_0.xml 684B
  46. springboot-neo4j-demo/.idea/libraries/Maven__org_junit_platform_junit_platform_engine_1_7_0.xml 677B
  47. springboot-neo4j-demo/.idea/libraries/Maven__org_mockito_mockito_core_3_6_28.xml 593B
  48. springboot-neo4j-demo/.idea/libraries/Maven__org_mockito_mockito_junit_jupiter_3_6_28.xml 656B
  49. springboot-neo4j-demo/.idea/libraries/Maven__org_neo4j_driver_neo4j_java_driver_4_1_1.xml 641B
  50. springboot-neo4j-demo/.idea/libraries/Maven__org_neo4j_neo4j_cypher_dsl_2020_1_4.xml 627B
  51. springboot-neo4j-demo/.idea/libraries/Maven__org_neo4j_neo4j_ogm_api_4_0_0.xml 585B
  52. springboot-neo4j-demo/.idea/libraries/Maven__org_neo4j_neo4j_ogm_core_4_0_0.xml 592B
  53. springboot-neo4j-demo/.idea/libraries/Maven__org_objenesis_objenesis_3_1.xml 559B
  54. springboot-neo4j-demo/.idea/libraries/Maven__org_opentest4j_opentest4j_1_2_0.xml 584B
  55. springboot-neo4j-demo/.idea/libraries/Maven__org_ow2_asm_asm_5_0_4.xml 523B
  56. springboot-neo4j-demo/.idea/libraries/Maven__org_projectlombok_lombok_1_18_16.xml 582B
  57. springboot-neo4j-demo/.idea/libraries/Maven__org_reactivestreams_reactive_streams_1_0_3.xml 646B
  58. springboot-neo4j-demo/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_5_0.xml 588B
  59. springboot-neo4j-demo/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_30.xml 585B
  60. springboot-neo4j-demo/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_30.xml 564B
  61. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_boot_spring_boot_2_4_2.xml 631B
  62. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_4_2.xml 729B
  63. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_4_2.xml 687B
  64. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_aop_2_4_2.xml 715B
  65. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_neo4j_2_4_2.xml 764B
  66. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_2_4_2.xml 722B
  67. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_4_2.xml 743B
  68. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_2_4_2.xml 722B
  69. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_2_4_2.xml 736B
  70. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_2_4_2.xml 715B
  71. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_2_4_2.xml 666B
  72. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_4_2.xml 764B
  73. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_data_spring_data_commons_2_4_3.xml 687B
  74. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_data_spring_data_neo4j_6_0_3.xml 673B
  75. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_spring_aop_5_3_3.xml 604B
  76. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_spring_beans_5_3_3.xml 618B
  77. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_spring_context_5_3_3.xml 632B
  78. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_spring_core_5_3_3.xml 611B
  79. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_spring_expression_5_3_3.xml 653B
  80. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_spring_jcl_5_3_3.xml 604B
  81. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_spring_test_5_3_3.xml 611B
  82. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_spring_tx_5_3_3.xml 597B
  83. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_spring_web_5_3_3.xml 604B
  84. springboot-neo4j-demo/.idea/libraries/Maven__org_springframework_spring_webmvc_5_3_3.xml 625B
  85. springboot-neo4j-demo/.idea/libraries/Maven__org_xmlunit_xmlunit_core_2_7_0.xml 586B
  86. springboot-neo4j-demo/.idea/libraries/Maven__org_yaml_snakeyaml_1_27.xml 546B
  87. springboot-neo4j-demo/.idea/misc.xml 555B
  88. springboot-neo4j-demo/.idea/modules.xml 255B
  89. springboot-neo4j-demo/.idea/uiDesigner.xml 8.71KB
  90. springboot-neo4j-demo/.idea/workspace.xml 8.71KB
  91. springboot-neo4j-demo/HELP.md 848B
  92. springboot-neo4j-demo/demo.iml 8.93KB
  93. springboot-neo4j-demo/pom.xml 2.32KB
  94. springboot-neo4j-demo/src/
  95. springboot-neo4j-demo/src/main/
  96. springboot-neo4j-demo/src/main/java/
  97. springboot-neo4j-demo/src/main/java/com/
  98. springboot-neo4j-demo/src/main/java/com/DemoApplication.java 398B
  99. springboot-neo4j-demo/src/main/java/com/neo4j/
  100. springboot-neo4j-demo/src/main/java/com/neo4j/aspect/
  101. springboot-neo4j-demo/src/main/java/com/neo4j/aspect/RepositoryAspect.java 773B
  102. springboot-neo4j-demo/src/main/java/com/neo4j/controller/
  103. springboot-neo4j-demo/src/main/java/com/neo4j/controller/Neo4jController.java 6.99KB
  104. springboot-neo4j-demo/src/main/java/com/neo4j/domain/
  105. springboot-neo4j-demo/src/main/java/com/neo4j/domain/Movie.java 1.18KB
  106. springboot-neo4j-demo/src/main/java/com/neo4j/domain/Person.java 738B
  107. springboot-neo4j-demo/src/main/java/com/neo4j/domain/Roles.java 662B
  108. springboot-neo4j-demo/src/main/java/com/neo4j/domain/SystemEntity.java 838B
  109. springboot-neo4j-demo/src/main/java/com/neo4j/repository/
  110. springboot-neo4j-demo/src/main/java/com/neo4j/repository/MovieRepository.java 410B
  111. springboot-neo4j-demo/src/main/java/com/neo4j/repository/PersonRepository.java 352B
  112. springboot-neo4j-demo/src/main/java/com/neo4j/repository/SystemRepository.java 1.74KB
  113. springboot-neo4j-demo/src/main/resources/
  114. springboot-neo4j-demo/src/main/resources/application.properties 202B
  115. springboot-neo4j-demo/src/main/resources/static/
  116. springboot-neo4j-demo/src/main/resources/static/index.html 103B
  117. springboot-neo4j-demo/src/test/
  118. springboot-neo4j-demo/src/test/java/
  119. springboot-neo4j-demo/src/test/java/com/
  120. springboot-neo4j-demo/src/test/java/com/example/
  121. springboot-neo4j-demo/src/test/java/com/example/demo/
  122. springboot-neo4j-demo/src/test/java/com/example/demo/DemoApplicationTests.java 215B
  123. springboot-neo4j-demo/target/
  124. springboot-neo4j-demo/target/classes/
  125. springboot-neo4j-demo/target/classes/application.properties 202B
  126. springboot-neo4j-demo/target/classes/com/
  127. springboot-neo4j-demo/target/classes/com/DemoApplication.class 747B
  128. springboot-neo4j-demo/target/classes/com/neo4j/
  129. springboot-neo4j-demo/target/classes/com/neo4j/aspect/
  130. springboot-neo4j-demo/target/classes/com/neo4j/aspect/RepositoryAspect.class 1.54KB
  131. springboot-neo4j-demo/target/classes/com/neo4j/controller/
  132. springboot-neo4j-demo/target/classes/com/neo4j/controller/Neo4jController.class 8.46KB
  133. springboot-neo4j-demo/target/classes/com/neo4j/domain/
  134. springboot-neo4j-demo/target/classes/com/neo4j/domain/Movie.class 4.48KB
  135. springboot-neo4j-demo/target/classes/com/neo4j/domain/Person.class 2.61KB
  136. springboot-neo4j-demo/target/classes/com/neo4j/domain/Roles.class 2.85KB
  137. springboot-neo4j-demo/target/classes/com/neo4j/domain/SystemEntity.class 1.24KB
  138. springboot-neo4j-demo/target/classes/com/neo4j/repository/
  139. springboot-neo4j-demo/target/classes/com/neo4j/repository/MovieRepository.class 568B
  140. springboot-neo4j-demo/target/classes/com/neo4j/repository/PersonRepository.class 509B
  141. springboot-neo4j-demo/target/classes/com/neo4j/repository/SystemRepository.class 2KB
  142. springboot-neo4j-demo/target/classes/static/
  143. springboot-neo4j-demo/target/classes/static/index.html 103B
  144. springboot-neo4j-demo/target/generated-sources/
  145. springboot-neo4j-demo/target/generated-sources/annotations/
  146. springboot-neo4j-demo/target/generated-test-sources/
  147. springboot-neo4j-demo/target/generated-test-sources/test-annotations/
  148. springboot-neo4j-demo/target/test-classes/
  149. springboot-neo4j-demo/target/test-classes/com/
  150. springboot-neo4j-demo/target/test-classes/com/example/
  151. springboot-neo4j-demo/target/test-classes/com/example/demo/
  152. springboot-neo4j-demo/target/test-classes/com/example/demo/DemoApplicationTests.class 531B
0评论
提交 加载更多评论
其他资源 Perl CentOS7 64位操作系统依赖包
1)适用于CentOS 64位操作系统,所有文件均为 64 位操作系统的文件 2)有些人的资源是 64 + 32 混搭着来的,没法安装;
Java 四则运算计算器
利用JavaSwing实现的简单四则运算计算器
行政区划代码名称csv格式
行政区划代码名称csv格式
wu-et-al-2021-non-line-of-sight-imaging-over-1-43-km(!!免费!!)
原文,word翻译,PDF翻译 非视距成像|光学成像|计算成像|交通|1.43km|徐飞虎
车险索赔预测-可使用数据集
车险索赔预测数据集,包含训练集、测试集和数据集字段说明。
车险索赔预测-可使用数据集
library demo - OUC c#大作业
ouc c#课程大作业
Flux Modelscope 本地部署
1. Notebook 文件包括,安装ComfyUI、模型下载、ComfyUI 启动 2. ComfyUI 配置文件
kafka(2).zip
kafka(2).zip