详细介绍:springboot mysql/mariadb迁移成oceanbase

前言:项目架构为springboot+mybatis-plus+mysql

1.部署oceanbase服务

2.springboot工程引入oceanbase依赖(即ob驱动)

ps:删除原有的mysql/mariadb依赖

<dependency>
    <groupId>com.oceanbase</groupId>
    <artifactId>oceanbase-client</artifactId>
    <version>2.4.14</version>
</dependency>

3.修改springboot方案数据库配置

    url:jdbc:oceanbase://ip:端口/scheme名
    username:用户名@租户名#集群名 或者 集群名:租户名:用户名
    password: 密码
    driver-class-name: com.oceanbase.jdbc.Driver

ps:这里可以应用mysql驱动和协议,因为oceanbase兼容mysql协议,但不推荐。

druid链接池,必须指定druid防火墙的类型:就是假如使用的

filters: stat,slf4j

如果是多数据源,建议使用hikari,因为druid不兼容oceanbase 

4.升级mybatis-plus版本

4.1升级mybatis-plus版本

如果项目mybatis-plus版本低于3.5.2.*,应该升级,我这里升级为3.5.3.1

因为低版本的mybatis-plus不兼容oceanbase,即低版本的Dbtype.calss中缺少oceanbase枚举值,即下图标红的内容:

4.2 修改MybatisPlusConfig类

高版本Mybatis-plus的分页依赖于PaginationInnerInterceptor插件 ,低版本是PaginationInterceptor类。如下图:

posted @ 2025-07-22 08:26  yfceshi  阅读(91)  评论(0)    收藏  举报