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.总结

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

目录
相关文章
|
12月前
|
NoSQL Java 网络安全
SpringBoot启动时连接Redis报错:ERR This instance has cluster support disabled - 如何解决?
通过以上步骤一般可以解决由于配置不匹配造成的连接错误。在调试问题时,一定要确保服务端和客户端的Redis配置保持同步一致。这能够确保SpringBoot应用顺利连接到正确配置的Redis服务,无论是单机模式还是集群模式。
817 5
|
人工智能 自然语言处理 安全
Python构建MCP服务器:从工具封装到AI集成的全流程实践
MCP协议为AI提供标准化工具调用接口,助力模型高效操作现实世界。
1953 1
|
JSON 分布式计算 大数据
springboot项目集成大数据第三方dolphinscheduler调度器
springboot项目集成大数据第三方dolphinscheduler调度器
882 3
|
缓存 JSON 前端开发
第07课:Spring Boot集成Thymeleaf模板引擎
第07课:Spring Boot集成Thymeleaf模板引擎
1092 0
第07课:Spring Boot集成Thymeleaf模板引擎
|
Java 关系型数据库 MySQL
springboot项目集成dolphinscheduler调度器 实现datax数据同步任务
springboot项目集成dolphinscheduler调度器 实现datax数据同步任务
1177 2
|
分布式计算 大数据 Java
springboot项目集成大数据第三方dolphinscheduler调度器 执行/停止任务
springboot项目集成大数据第三方dolphinscheduler调度器 执行/停止任务
383 0
|
存储 人工智能 Java
Springboot集成AI Springboot3 集成阿里云百炼大模型CosyVoice2 实现Ai克隆语音(未持久化存储)
本项目基于Spring Boot 3.5.3与Java 17,集成阿里云百炼大模型CosyVoice2实现音色克隆与语音合成。内容涵盖项目搭建、音色创建、音频合成、音色管理等功能,适用于希望快速掌握Spring Boot集成语音AI技术的开发者。需提前注册阿里云并获取API Key。
|
12月前
|
弹性计算 运维 安全
阿里云轻量应用服务器与云服务器ECS啥区别?新手帮助教程
阿里云轻量应用服务器适合个人开发者搭建博客、测试环境等低流量场景,操作简单、成本低;ECS适用于企业级高负载业务,功能强大、灵活可扩展。二者在性能、网络、镜像及运维管理上差异显著,用户应根据实际需求选择。
942 10
|
12月前
|
弹性计算 ice
阿里云4核8g服务器多少钱一年?1个月和1小时价格,省钱购买方法分享
阿里云4核8G服务器价格因实例类型而异,经济型e实例约159元/月,计算型c9i约371元/月,按小时计费最低0.45元。实际购买享折扣,1年最高可省至1578元,附主流ECS实例及CPU型号参考。
940 8

热门文章

最新文章