Neo4j【付诸实践 01】SpringBoot集成报错org.neo4j.driver.exceptions.ClientException:服务器不支持此驱动程序支持的任何协议版本(解决+源代码)

简介: Neo4j【付诸实践 01】SpringBoot集成报错org.neo4j.driver.exceptions.ClientException:服务器不支持此驱动程序支持的任何协议版本(解决+源代码)

SpringBoot集成Neo4j调试的时候报:

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.

在网络上查找解决方法未果,但是看得出是驱动程序和服务器版本彼此不兼容的问题,由于服务器的JDK是1.8的,所以最初没有部署最新版本的neo4j(报错时使用的版本是3.4.5),调试项目的依赖版本调整也无法解决问题,最终重新部署了(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:7687
    authentication:
      username: neo4j
      password: neo4j1

2.源代码

/**
 * 部门类
 */
@NodeEntity(label = "dept")
@Data
@Builder
public class Dept {
    @Id
    @GeneratedValue
    private Long id;
    @Property(name = "deptName")
    private String deptName;
}
/**
 * 关系类
 */
@RelationshipEntity(type = "relationShip")
@Data
@Builder
public class RelationShip {
    @Id
    @GeneratedValue
    private Long id;
    @StartNode
    private Dept parent;
    @EndNode
    private Dept child;
}
/**
 * 两个继承Neo4jRepository的接口
 */
@Repository
public interface DeptRepository extends Neo4jRepository<Dept,Long> {}
@Repository
public interface RelationShipRepository extends Neo4jRepository<RelationShip, Long> {}
/**
 * 测试方法类
 */
@RestController
public class TestController {
    @Autowired
    private DeptRepository deptRepository;
    @Autowired
    private RelationShipRepository relationShipRepository;
    @GetMapping("create")
    public void create() {
        Dept root = Dept.builder().deptName("软件部").build();
        Dept dept1 = Dept.builder().deptName("架构组").build();
        Dept dept2 = Dept.builder().deptName("开发组").build();
        Dept dept3 = Dept.builder().deptName("实施组").build();
        Dept dept21 = Dept.builder().deptName("前端技术部").build();
        Dept dept22 = Dept.builder().deptName("后端技术部").build();
        Dept dept23 = Dept.builder().deptName("测试技术部").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.结果

4.总结

回想一下,我是不是应该先测试一下不同版本的依赖再去重新部署呢?

目录
相关文章
|
10月前
|
XML Java Nacos
Spring Boot 整合Nacos 版本兼容适配 史上最详细文档
本文介绍SpringBoot整合Nacos的完整流程,涵盖Nacos下载安装、配置中心与服务发现集成、版本兼容性问题及实战配置。重点解决SpringBoot 3.3.0与Nacos版本适配难题,推荐使用Spring Cloud Alibaba方案,并提供项目开源地址供参考学习。
|
11月前
|
人工智能 自然语言处理 安全
Python构建MCP服务器:从工具封装到AI集成的全流程实践
MCP协议为AI提供标准化工具调用接口,助力模型高效操作现实世界。
1795 1
|
JSON 分布式计算 大数据
springboot项目集成大数据第三方dolphinscheduler调度器
springboot项目集成大数据第三方dolphinscheduler调度器
771 3
|
缓存 JSON 前端开发
第07课:Spring Boot集成Thymeleaf模板引擎
第07课:Spring Boot集成Thymeleaf模板引擎
1006 0
第07课:Spring Boot集成Thymeleaf模板引擎
|
Java 关系型数据库 MySQL
springboot项目集成dolphinscheduler调度器 实现datax数据同步任务
springboot项目集成dolphinscheduler调度器 实现datax数据同步任务
1086 2
|
分布式计算 大数据 Java
springboot项目集成大数据第三方dolphinscheduler调度器 执行/停止任务
springboot项目集成大数据第三方dolphinscheduler调度器 执行/停止任务
336 0
|
存储 人工智能 Java
Springboot集成AI Springboot3 集成阿里云百炼大模型CosyVoice2 实现Ai克隆语音(未持久化存储)
本项目基于Spring Boot 3.5.3与Java 17,集成阿里云百炼大模型CosyVoice2实现音色克隆与语音合成。内容涵盖项目搭建、音色创建、音频合成、音色管理等功能,适用于希望快速掌握Spring Boot集成语音AI技术的开发者。需提前注册阿里云并获取API Key。
|
Java Maven Docker
gitlab-ci 集成 k3s 部署spring boot 应用
gitlab-ci 集成 k3s 部署spring boot 应用

热门文章

最新文章