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

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

目录
相关文章
|
19天前
|
Java Linux
Springboot 解决linux服务器下获取不到项目Resources下资源
Springboot 解决linux服务器下获取不到项目Resources下资源
|
20天前
|
消息中间件 Java Kafka
Springboot集成高低版本kafka
Springboot集成高低版本kafka
|
26天前
|
NoSQL Java Redis
SpringBoot集成Redis解决表单重复提交接口幂等(亲测可用)
SpringBoot集成Redis解决表单重复提交接口幂等(亲测可用)
301 0
|
2天前
|
Java Spring
Spring Boot脚手架集成校验框架
Spring Boot脚手架集成校验框架
6 0
|
3天前
|
Java Docker 容器
SpringBoot项目集成XXL-job
SpringBoot项目集成XXL-job
|
5天前
|
Java 关系型数据库 数据库
【SpringBoot系列】微服务集成Flyway
【4月更文挑战第7天】SpringBoot微服务集成Flyway
【SpringBoot系列】微服务集成Flyway
|
19天前
|
安全 Java
Springboot2.1.1版本升级到2.3.10版本报错合集及解决办法
Springboot2.1.1版本升级到2.3.10版本报错合集及解决办法
|
20天前
|
SQL Java 调度
SpringBoot集成quartz定时任务trigger_state状态ERROR解决办法
SpringBoot集成quartz定时任务trigger_state状态ERROR解决办法
|
Java
记一次springboot版本升级问题
spring-boot-starter-parent 2.6.6
1114 0
记一次springboot版本升级问题
|
27天前
|
Java API Spring
SpringBoot项目调用HTTP接口5种方式你了解多少?
SpringBoot项目调用HTTP接口5种方式你了解多少?
80 2