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