springboot框架集成neo4j+d3.js
project-neo4j
一、功能介绍:
-
连接mysql、neo4j,实现将mysql数据插入neo4j中!
-
对neo4j数据进行增删改查,统计分析、关系遍历等功能 !
二、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】
三、部署说明
-
下载neo4j安装程序
http://download.csdn.net/download/npf_java/10197711 -
创建mysql数据库
a)运行opensearch.sql脚本创建数据库
b)通过navicat工具初始化数据,还原180118183225.psc文件 -
将mysql数据导入neo4j中
执行junit测试类KeyWordTest中的addKeyWordNode、addNewsNode方法
四、更新说明
2018-01-24(统计)
2018-01-23(D3.js实现页面效果展示)
建议使用D3.js作为前端展示效果 (Neo4j内置的页面展示使用的是D3.js库)
- 【D3.js官网】
- https://d3js.org/
-
- 【D3.js中文实例、API】
- https://github.com/d3/d3/wiki/CN-Home
-
- 【D3.js[2.5.0] 学习网站】
- http://www.ourd3js.com/wordpress/category/data-driven-documents/
-
- 【D3.js[4.12.2] 力导向图的制作】
- https://github.com/d3/d3-force
- https://bl.ocks.org/mbostock/9a8124ccde3a4e9625bc413b48f14b30
-
- 【springBoot thymeleaf模板】
- http://jisonami.iteye.com/blog/2301387
-
- Maven的资源文件目录:/src/java/resources
- spring-boot项目静态文件目录:/src/java/resources/static
- spring-boot项目模板文件目录:/src/java/resources/templates
- spring-boot静态首页的支持,即index.html放在以下目录结构会直接映射到应用的根目录下:
- classpath:/META-INF/resources/index.html
- classpath:/resources/index.html
- classpath:/static/index.html
- calsspath:/public/index.html
2018-01-18(框架初步完成,初始化提交)
-
初始化提交项目相关代码
-
通过KeyWordTest类可以将mysql数据库中的keyword和news数据导入neo4j中
- /**
- * 包名:com.dbs.test.mysql
- * 功能:TODO 对关键字进行提取
- * 作者:hualn
- * 日期:2018年1月18日 下午4:25:02
- */
- @RunWith(SpringJUnit4ClassRunner.class)
- @SpringBootTest(classes = Neo4jApplication.class)
- public class KeyWordTest {
-
- private Logger logger = LoggerFactory.getLogger(getClass());
-
- /**
- * 关键字操作类
- */
- @Autowired
- private KeyWordRepository keyWordRepository;
-
- /**
- * 新闻操作类
- */
- @Autowired
- private NewsRepository newsRepository;
-
- /**
- * mysql--JDBC连接
- */
- @Autowired
- private JdbcTemplate jdbcTemplate;
-
- /**
- * 将keyWord关键字全部抽取到neo4j中
- */
- @Test
- public void addKeyWordNode(){
- String keySql = "select t.AIRCRAFT from news_keyword t group by t.AIRCRAFT ";
-
- List<Map<String, Object>> keyList = jdbcTemplate.queryForList(keySql);
-
- for (Map<String, Object> obj : keyList) {
- String keyword = obj.get("AIRCRAFT").toString();
- if(StringUtils.isNotBlank(keyword)){
- keyWordRepository.save(new KeyWord(keyword));
- }
- }
-
- logger.info("******************共导入关键字("+keyList.size()+")个***********************");
-
- }
-
- /**
- * 将新闻节点全部抽取到neo4j中
- */
- @Test
- public void addNewsNode(){
- String newsSql = "select n.TITLE,max(t.AIRCRAFT) keyword from news_keyword t
- left join datasource_new n on t.NEWID = n.ID GROUP BY n.TITLE ";
-
- List<Map<String, Object>> newsList = jdbcTemplate.queryForList(newsSql);
-
- //新闻类
- News news= null;
- //关键字
- KeyWord keyWord = null;
- for (Map<String, Object> obj : newsList) {
- String title = obj.get("TITLE").toString();
- String keyword = obj.get("KEYWORD").toString();
-
- news = new News(title);
- keyWord = keyWordRepository.findByName(keyword);
- news.setKeywords(Lists.newArrayList(keyWord));
- newsRepository.save(news);
- }
-
- }
-
- }
-
2018-01-15------>2018-01-17(框架搭建中)
- 学习Neo4j推荐书籍
《Neo4j权威指南 图数据库 大数据时代的新利器》
- 参考网站
- 【官网】
- https://neo4j.com/
-
- 【Neo4j 图数据库在社交网络等领域的应用】 **(重点看)**
- http://gitbook.cn/books/5a33782c5778440a9d906017/index.html
- 实例学习
- 【中文学习教程】https://www.w3cschool.cn/neo4j/
-
- 【英文学习教程】https://neo4j.com/graphgists/?category=sports-and-recreation
- 安装
- Neo4j 下载地址:https://neo4j.com/download/other-releases/
-
- 【Neo4j 第一篇:在Windows环境中安装Neo4j】
- https://www.cnblogs.com/ljhdo/archive/2017/05/19/5521577.html
-
- 效果展示
- 搜狗人物搜索 https://www.sogou.com/tupu/person.html?q=姚明
-
- 搜索引擎和知识图谱那些事 http://blog.csdn.net/eastmount/article/details/46874155
- Java操作neo4j
- http://bboyjing.github.io/2016/07/15/Neo4j学习笔记九【Spring-Data-Neo4j】/
-
- https://github.com/bboyjing/neo4j_sample
-
- 【springboot和neo4j的集成】
- https://www.jianshu.com/p/33d50fac06b4
-
-
- 【官网API】
- https://docs.spring.io/spring-data/neo4j/docs/4.2.9.RELEASE/reference/html/
- https://docs.spring.io/spring-data/neo4j/docs/4.2.9.RELEASE/api/
-
- 【github相关demo】
- https://github.com/neo4j-examples/
- https://github.com/neo4j-examples/movies-java-spring-data-neo4j
- https://github.com/neo4j-examples/neo4j-sdn-ogm-issue-report-template


浙公网安备 33010602011771号