springboot框架集成neo4j+d3.js


project-neo4j

一、功能介绍:

  1. 连接mysql、neo4j,实现将mysql数据插入neo4j中!

  2. 对neo4j数据进行增删改查,统计分析、关系遍历等功能 !

  3. 源码下载地址:https://download.csdn.net/download/npf_java/10222241

二、JAR说明:

  • springboot【1.5.9】

  • pring-boot-starter-data-neo4j【4.2.9】

  • mybatis-spring-boot-starter【1.3.1】

  • mapper-spring-boot-starter【1.1.4】

  • pagehelper-spring-boot-starter【1.2.1】

  • druid-spring-boot-starter【1.1.0】

  • fastjson【1.2.12】

  • com.google.guava【19.0】

三、部署说明

  1. 下载neo4j安装程序
    http://download.csdn.net/download/npf_java/10197711

  2. 创建mysql数据库
    a)运行opensearch.sql脚本创建数据库
    b)通过navicat工具初始化数据,还原180118183225.psc文件

  3. 将mysql数据导入neo4j中
    执行junit测试类KeyWordTest中的addKeyWordNode、addNewsNode方法

四、更新说明

2018-01-24(统计)

2018-01-23(D3.js实现页面效果展示)

建议使用D3.js作为前端展示效果 (Neo4j内置的页面展示使用的是D3.js库)


    
    
   
   
  1. 【D3.js官网】
  2. https://d3js.org/
  3. 【D3.js中文实例、API】
  4. https://github.com/d3/d3/wiki/CN-Home
  5. 【D3.js[2.5.0] 学习网站】
  6. http://www.ourd3js.com/wordpress/category/data-driven-documents/
  7. 【D3.js[4.12.2] 力导向图的制作】
  8. https://github.com/d3/d3-force
  9. https://bl.ocks.org/mbostock/9a8124ccde3a4e9625bc413b48f14b30
  10. 【springBoot thymeleaf模板】
  11. http://jisonami.iteye.com/blog/2301387
  12. Maven的资源文件目录:/src/java/resources
  13. spring-boot项目静态文件目录:/src/java/resources/static
  14. spring-boot项目模板文件目录:/src/java/resources/templates
  15. spring-boot静态首页的支持,即index.html放在以下目录结构会直接映射到应用的根目录下:
  16. classpath:/META-INF/resources/index.html
  17. classpath:/resources/index.html
  18. classpath:/static/index.html
  19. calsspath:/public/index.html

2018-01-18(框架初步完成,初始化提交)

  1. 初始化提交项目相关代码

  2. 通过KeyWordTest类可以将mysql数据库中的keyword和news数据导入neo4j中


    
    
   
   
  1. /**
  2. * 包名:com.dbs.test.mysql
  3. * 功能:TODO 对关键字进行提取
  4. * 作者:hualn
  5. * 日期:2018年1月18日 下午4:25:02
  6. */
  7. @RunWith(SpringJUnit4ClassRunner.class)
  8. @SpringBootTest(classes = Neo4jApplication.class)
  9. public class KeyWordTest {
  10. private Logger logger = LoggerFactory.getLogger(getClass());
  11. /**
  12. * 关键字操作类
  13. */
  14. @Autowired
  15. private KeyWordRepository keyWordRepository;
  16. /**
  17. * 新闻操作类
  18. */
  19. @Autowired
  20. private NewsRepository newsRepository;
  21. /**
  22. * mysql--JDBC连接
  23. */
  24. @Autowired
  25. private JdbcTemplate jdbcTemplate;
  26. /**
  27. * 将keyWord关键字全部抽取到neo4j中
  28. */
  29. @Test
  30. public void addKeyWordNode(){
  31. String keySql = "select t.AIRCRAFT from news_keyword t group by t.AIRCRAFT ";
  32. List <Map<String, Object>> keyList = jdbcTemplate.queryForList(keySql);
  33. for (Map <String, Object> obj : keyList) {
  34. String keyword = obj.get("AIRCRAFT").toString();
  35. if(StringUtils.isNotBlank(keyword)){
  36. keyWordRepository.save(new KeyWord(keyword));
  37. }
  38. }
  39. logger.info("******************共导入关键字("+keyList.size()+")个***********************");
  40. }
  41. /**
  42. * 将新闻节点全部抽取到neo4j中
  43. */
  44. @Test
  45. public void addNewsNode(){
  46. String newsSql = "select n.TITLE,max(t.AIRCRAFT) keyword from news_keyword t
  47. left join datasource_new n on t.NEWID = n.ID GROUP BY n.TITLE ";
  48. List <Map<String, Object>> newsList = jdbcTemplate.queryForList(newsSql);
  49. //新闻类
  50. News news= null;
  51. //关键字
  52. KeyWord keyWord = null;
  53. for (Map <String, Object> obj : newsList) {
  54. String title = obj.get("TITLE").toString();
  55. String keyword = obj.get("KEYWORD").toString();
  56. news = new News(title);
  57. keyWord = keyWordRepository.findByName(keyword);
  58. news.setKeywords(Lists.newArrayList(keyWord));
  59. newsRepository.save(news);
  60. }
  61. }
  62. }

2018-01-15------>2018-01-17(框架搭建中)

  1. 学习Neo4j推荐书籍
《Neo4j权威指南 图数据库 大数据时代的新利器》

   
   
  
  
  1. 参考网站

    
    
   
   
  1. 【官网】
  2. https://neo4j.com/
  3. 【Neo4j 图数据库在社交网络等领域的应用】 **(重点看)**
  4. http://gitbook.cn/books/5a33782c5778440a9d906017/index.html
  1. 实例学习

    
    
   
   
  1. 【中文学习教程】https://www.w3cschool.cn/neo4j/
  2. 【英文学习教程】https://neo4j.com/graphgists/?category=sports-and-recreation
  1. 安装

    
    
   
   
  1. Neo4j 下载地址:https://neo4j.com/download/other-releases/
  2. 【Neo4j 第一篇:在Windows环境中安装Neo4j】
  3. https://www.cnblogs.com/ljhdo/archive/2017/05/19/5521577.html
  1. 效果展示

    
    
   
   
  1. 搜狗人物搜索 https://www.sogou.com/tupu/person.html?q=姚明
  2. 搜索引擎和知识图谱那些事 http://blog.csdn.net/eastmount/article/details/46874155
  1. Java操作neo4j

    
    
   
   
  1. http://bboyjing.github.io/2016/07/15/Neo4j学习笔记九【Spring-Data-Neo4j】/
  2. https://github.com/bboyjing/neo4j_sample
  3. 【springboot和neo4j的集成】
  4. https://www.jianshu.com/p/33d50fac06b4
  5. 【官网API】
  6. https://docs.spring.io/spring-data/neo4j/docs/4.2.9.RELEASE/reference/html/
  7. https://docs.spring.io/spring-data/neo4j/docs/4.2.9.RELEASE/api/
  8. 【github相关demo】
  9. https://github.com/neo4j-examples/
  10. https://github.com/neo4j-examples/movies-java-spring-data-neo4j
  11. https://github.com/neo4j-examples/neo4j-sdn-ogm-issue-report-template

五、效果展示

输入图片说明

 项目点评 ( 0 )


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM