【无标题】

第一次使用r2dbc,在一个四年的工程里。因为工程的dependencyManagement限制了依赖的版本:

复制代码
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-r2dbc</artifactId>
        </dependency>
        一开始用的下面这个:
        <dependency>
            <groupId>io.asyncer</groupId>
            <artifactId>r2dbc-mysql</artifactId>
            <version>1.4.0</version>
        </dependency>
        后来换成下面这个:
        <dependency>
            <groupId>dev.miku</groupId>
            <artifactId>r2dbc-mysql</artifactId>
            <version>0.8.2.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>

spring-boot-starter-data-r2dbc版本是2.3.9,

mysql-connector-java版本是8.0.27

r2dbc-mysql的版本是1.4.0

启动的时候报错误:
java.lang.NoSuchFieldError: LOCK_WAIT_TIMEOUT

搜到了一个github的oracle-r2dbc类库ISSUE页面,有人回答是版本不兼容导致的。spring-boot-starter-data-r2dbc如果是版本低,那么应该用r2dbc类库的0.8版本。mvnrepository中没有看到这个类库有0.9以下版本。直到看到这个贴子:

https://github.com/asyncer-io/r2dbc-mysql

Refer to the table below to determine the appropriate version of r2dbc-mysql for your project.

推荐的版本如下:

spring-boot-starter-data-r2dbc spring-data-r2dbc r2dbc-spi r2dbc-mysql(recommended)
3.0.* and above 3.0.* and above 1.0.0.RELEASE io.asyncer:r2dbc-mysql:1.4.0
2.7.* 1.5.* 0.9.1.RELEASE io.asyncer:r2dbc-mysql:0.9.7
2.6.* and below 1.4.* and below 0.8.6.RELEASE dev.miku:r2dbc-mysql:0.8.2
相关推荐
洋洋技术笔记1 天前
Spring Boot配置管理最佳实践
spring boot
用户8307196840822 天前
Spring Boot 项目中日期处理的最佳实践
java·spring boot
大道至简Edward2 天前
Spring Boot 2.7 + JDK 8 升级到 Spring Boot 3.x + JDK 17 完整指南
spring boot·后端
洋洋技术笔记2 天前
Spring Boot启动流程解析
spring boot·后端
怒放吧德德3 天前
Spring Boot 实战:RSA+AES 接口全链路加解密(防篡改 / 防重放)
java·spring boot·后端
李慕婉学姐3 天前
Springboot智慧社区系统设计与开发6n99s526(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
数据库·spring boot·后端
QQ5110082853 天前
python+springboot+django/flask的校园资料分享系统
spring boot·python·django·flask·node.js·php
WeiXin_DZbishe3 天前
基于django在线音乐数据采集的设计与实现-计算机毕设 附源码 22647
javascript·spring boot·mysql·django·node.js·php·html5
追风筝的人er3 天前
企业管理系统如何实现自定义首页与千人千面?RuoYi Office 给出了完整方案
vue.js·spring boot·spring cloud
Java水解3 天前
你真的会打印日志吗?基于 Spring Boot 的全方位日志指南
spring boot·后端