當(dāng)前位置:
首頁(yè) >
前端技术
> javascript
>内容正文
javascript
Neo4j【付诸实践 01】SpringBoot集成报错org.neo4j.driver.exceptions.ClientException:服务器不支持此驱动程序支持的任何协议版本(解决+源代码)
生活随笔
收集整理的這篇文章主要介紹了
Neo4j【付诸实践 01】SpringBoot集成报错org.neo4j.driver.exceptions.ClientException:服务器不支持此驱动程序支持的任何协议版本(解决+源代码)
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
SpringBoot集成Neo4j調(diào)試的時(shí)候報(bào):
org.neo4j.driver.exceptions.ClientException: The server does not support any of the protocol versions supported by this driver. Ensure that you are using driver and server versions that are compatible with one another.在網(wǎng)絡(luò)上查找解決方法未果,但是看得出是驅(qū)動(dòng)程序和服務(wù)器版本彼此不兼容的問題,由于服務(wù)器的JDK是1.8的,所以最初沒有部署最新版本的neo4j(報(bào)錯(cuò)時(shí)使用的版本是3.4.5),調(diào)試項(xiàng)目的依賴版本調(diào)整也無法解決問題,最終重新部署了(openjdk-11+28 和 neo4j-4.2.7)才解決問題。
1.依賴及配置
<!-- springboot 版本 2.5.1 --> <!--neo4j--> <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-neo4j</artifactId> </dependency> <!-- neo4j-ogm-http-driver --> <dependency><groupId>org.neo4j</groupId><artifactId>neo4j-ogm-http-driver</artifactId><version>2.1.5</version> </dependency>密碼是必須修改的
spring:neo4j:uri: bolt://aliyun:7687authentication:username: neo4jpassword: neo4j12.源代碼
/*** 部門類*/ @NodeEntity(label = "dept") @Data @Builder public class Dept {@Id@GeneratedValueprivate Long id;@Property(name = "deptName")private String deptName;}/*** 關(guān)系類*/ @RelationshipEntity(type = "relationShip") @Data @Builder public class RelationShip {@Id@GeneratedValueprivate Long id;@StartNodeprivate Dept parent;@EndNodeprivate Dept child; }/*** 兩個(gè)繼承Neo4jRepository的接口*/ @Repository public interface DeptRepository extends Neo4jRepository<Dept,Long> {} @Repository public interface RelationShipRepository extends Neo4jRepository<RelationShip, Long> {}/*** 測(cè)試方法類*/ @RestController public class TestController {@Autowiredprivate DeptRepository deptRepository;@Autowiredprivate RelationShipRepository relationShipRepository;@GetMapping("create")public void create() {Dept root = Dept.builder().deptName("軟件部").build();Dept dept1 = Dept.builder().deptName("架構(gòu)組").build();Dept dept2 = Dept.builder().deptName("開發(fā)組").build();Dept dept3 = Dept.builder().deptName("實(shí)施組").build();Dept dept21 = Dept.builder().deptName("前端技術(shù)部").build();Dept dept22 = Dept.builder().deptName("后端技術(shù)部").build();Dept dept23 = Dept.builder().deptName("測(cè)試技術(shù)部").build();List<Dept> deptList = new ArrayList<>(Arrays.asList(root, dept1, dept2, dept3, dept21, dept22, dept23));deptRepository.saveAll(deptList);RelationShip relationShip1 = RelationShip.builder().parent(root).child(dept1).build();RelationShip relationShip2 = RelationShip.builder().parent(root).child(dept2).build();RelationShip relationShip3 = RelationShip.builder().parent(root).child(dept3).build();RelationShip relationShip21 = RelationShip.builder().parent(dept2).child(dept21).build();RelationShip relationShip22 = RelationShip.builder().parent(dept2).child(dept22).build();RelationShip relationShip23 = RelationShip.builder().parent(dept2).child(dept23).build();List<RelationShip> relationShipList = new ArrayList<>(Arrays.asList(relationShip1, relationShip2, relationShip3, relationShip21, relationShip22, relationShip23));relationShipRepository.saveAll(relationShipList);}@GetMapping("deleteAll")public void deleteAll() {deptRepository.deleteAll();relationShipRepository.deleteAll();} }3.結(jié)果
4.總結(jié)
回想一下,我是不是應(yīng)該先測(cè)試一下不同版本的依賴再去重新部署呢?
總結(jié)
以上是生活随笔為你收集整理的Neo4j【付诸实践 01】SpringBoot集成报错org.neo4j.driver.exceptions.ClientException:服务器不支持此驱动程序支持的任何协议版本(解决+源代码)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【PostgreSQL保存】java.i
- 下一篇: Spring定时任务注解@Schedul