Springboot上同時集成mysql和Neo4j
一、集成mysql
1.1 在pom.xml配置文件裏面添加如下倉庫地址:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
1.2 在yml文件配置
(1)添加mysql連接地址和用戶名密碼
spring:
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:mysql://192.168.1.234:10139/weibo?characterEncoding=utf-8&useSSL=false
username: root
password: admin
driver-class-name: com.mysql.cj.jdbc.Driver
(2)之後再添加mybatis配置信息
mybatis:
mapper-locations: classpath*:mapper/*Mapper.xml
type-aliases-package: com.rdl.knowledgegraph2.entity
二、集成neo4j圖數據庫
首先我們來介紹一下Neo4j是一個世界領先的開源圖形數據庫。 它是由Neo技術使用Java語言完全開發的。
2.1 在pom.xml配置文件裏面添加如下倉庫地址
其中我們採用的是springdata+neo4j的方式去操作圖數據庫。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-neo4j</artifactId>
</dependency>
2.2在yml文件配置
添加Neo4j連接地址和用戶名密碼
spring:
data:
neo4j:
uri: http://127.0.0.1:7474
username: neo4j
password: admin
自此Springboot上同時集成mysql和Neo4j已經完成,您的每一個點贊和關注都將是博主前進的動力!!