1. timezone 警告
- application.yml 相关配置:
#
spring:
application:
name: xxx
r2dbc:
url: r2dbc:mysql://localhost:3306/test?serverTimezone=Asia/Shanghai
...
- 控制台警告内容如下:
[actor-tcp-nio-1] dev.miku.r2dbc.mysql.MySqlConnection : The server timezone is <?й???ʱ?> that's unknown, trying to use system default timezone
[actor-tcp-nio-1] dev.miku.r2dbc.mysql.MySqlConnection : The server timezone is <?й???ʱ?> that's unknown, trying to use system default timezone
[actor-tcp-nio-1] dev.miku.r2dbc.mysql.MySqlConnection : The server timezone is <?й???ʱ?> that's unknown, trying to use system default timezone
[actor-tcp-nio-1] dev.miku.r2dbc.mysql.MySqlConnection : The server timezone is <?й???ʱ?> that's unknown, trying to use system default timezone
[actor-tcp-nio-1] dev.miku.r2dbc.mysql.MySqlConnection : The server timezone is <?й???ʱ?> that's unknown, trying to use system default timezone
[actor-tcp-nio-1] dev.miku.r2dbc.mysql.MySqlConnection : The server timezone is <?й???ʱ?> that's unknown, trying to use system default timezone
[actor-tcp-nio-1] dev.miku.r2dbc.mysql.MySqlConnection : The server timezone is <?й???ʱ?> that's unknown, trying to use system default timezone
[actor-tcp-nio-1] dev.miku.r2dbc.mysql.MySqlConnection : The server timezone is <?й???ʱ?> that's unknown, trying to use system default timezone
- 如上: 虽然已经配置了 timezone ,但仍然有警告。
- 经查询 官方(https://github.com/mirromutth/r2dbc-mysql)说明,timezone 相关配置如下:
- 也就是需要将 application.yml 相关配置 修改为如下:
#
spring:
application:
name: xxx
r2dbc:
url: r2dbc:mysql://localhost:3306/test?serverZoneId=Asia/Shanghai
...
- 修改后实测不报警告了:
2. dev.miku.r2dbc-mysql 与 spring-boot-starter-parent 兼容性问题
- 当 pom.xml 相关配置如下时(r2dbc-mysql 不指定具体版本号):
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<!--<version>2.7.10</version>-->
<version>2.6.1</version>
<!--<relativePath/> <!– lookup parent from repository –>-->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-r2dbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>dev.miku</groupId>
<artifactId>r2dbc-mysql</artifactId>
<scope>runtime</scope>
</dependency>
<!--<dependency>
<groupId>io.asyncer</groupId>
<artifactId>r2dbc-mysql</artifactId>
<version>1.0.0</version>
</dependency>-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!--<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
- 使用 2.7.10 或者 3.xx 时不会引入 r2dbc-mysql,mysql-connector-java也就是说 spring-boot-starter-parent 没有在
<dependencyManagement>
中定义相关的版本; - 实测 使用 2.6.1 或者 2.3.7.RELEASE 可以引入 r2dbc-mysql,mysql-connector-java 这两个依赖;
以下为猜测
- 个人猜测高版本可能要用
dev.miku.r2dbc-mysql
的继任者io.asyncer.r2dbc-mysql
但是到目前为止 maven 中央仓库还没有io.asyncer.r2dbc-mysql: 1.0.0
但是有另外一个 :
<dependency>
<groupId>com.github.jasync-sql</groupId>
<artifactId>jasync-mysql</artifactId>
<version>2.1.16</version>
</dependency>
- 我不知它们3者什么关系,我也没细看文档,以上都是瞎猜的。