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月前
|
人工智能 自然语言处理 安全
代码静态扫描工具集成与实践
代码静态扫描工具(Static Application Security Testing, SAST)是在不运行代码的情况下,通过分析源代码或二进制代码来发现潜在安全漏洞、代码缺陷和质量问题的工具
1134 4
|
10月前
|
Java 测试技术 API
自动化测试工具集成及实践
自动化测试用例的覆盖度及关键点最佳实践、自动化测试工具、集成方法、自动化脚本编写等(兼容多语言(Java、Python、Go、C++、C#等)、多框架(Spring、React、Vue等))
757 6
|
10月前
|
安全 JavaScript 前端开发
安全漏洞检测集成及实践:SAST/DAST工具集成指南
通过合理集成和配置SAST/DAST工具,可以显著提升应用程序的安全性,并在开发早期发现和修复漏洞,降低安全风险和维护成本
1098 4
|
10月前
|
机器学习/深度学习 边缘计算 数据可视化
MyEMS 深度解析:碳管理赋能与系统集成的实践路径
MyEMS 是一款集碳管理与能源优化于一体的开源系统,具备多标准碳核算、碳足迹可视化、碳成本分析等功能,助力企业实现精准碳减排。系统支持与工业、建筑、政务平台等多系统集成,打破数据孤岛,提升能效。依托活跃的开源社区与丰富实践案例,MyEMS 持续迭代,推动绿色转型。
601 1
|
11月前
|
人工智能 自然语言处理 安全
Python构建MCP服务器:从工具封装到AI集成的全流程实践
MCP协议为AI提供标准化工具调用接口,助力模型高效操作现实世界。
1740 1
|
11月前
|
供应链 监控 搜索推荐
35页PPT|零售行业自助数据分析方法论:指标体系构建平台集成、会员与商品精细化运营实践
在零售行业环境剧变的背景下,传统“人找货”模式正被“货找人”取代。消费者需求日益个性化,购买路径多元化,企业亟需构建统一的指标体系,借助BI平台实现数据驱动的精细化运营。本文从指标体系构建、平台集成到会员与商品运营实践,系统梳理零售经营分析的方法论,助力企业实现敏捷决策与业务闭环。
35页PPT|零售行业自助数据分析方法论:指标体系构建平台集成、会员与商品精细化运营实践
|
12月前
|
JSON 分布式计算 大数据
springboot项目集成大数据第三方dolphinscheduler调度器
springboot项目集成大数据第三方dolphinscheduler调度器
744 3
|
12月前
|
缓存 JSON 前端开发
第07课:Spring Boot集成Thymeleaf模板引擎
第07课:Spring Boot集成Thymeleaf模板引擎
974 0
第07课:Spring Boot集成Thymeleaf模板引擎
|
分布式计算 大数据 Java
springboot项目集成大数据第三方dolphinscheduler调度器 执行/停止任务
springboot项目集成大数据第三方dolphinscheduler调度器 执行/停止任务
326 0

热门文章

最新文章