不可乘快而多事,不可因倦而鲜终。——菜根谭

首先docker跑一个实例

1
2
3
Github-Id-VampireAchao:~ achao$ docker run -p 2881:2881 --name shenyu-oceanbase -e MINI_MODE=0 -e ROOT_PASSWORD=12345678 -d oceanbase/oceanbase-ce
ed75d5a951daa4eaa8173c43bb65b27e1126f3063488ad1deafead941d6f2ff5
Github-Id-VampireAchao:~ achao$

由于oceanbase本身良好的语法兼容性,mysql模式语法不用修改,因此这里只针对驱动进行兼容

https://github.com/apache/shenyu/pull/5617

引入依赖:

1
2
3
4
5
<dependency>
<groupId>com.oceanbase</groupId>
<artifactId>oceanbase-client</artifactId>
<version>${oceanbase.version}</version>
</dependency>

版本是<oceanbase.version>2.4.12</oceanbase.version>

这边主要是需要注册pagehelper的方言:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import com.github.pagehelper.dialect.helper.MySqlDialect;
import com.github.pagehelper.page.PageAutoDialect;
import org.springframework.beans.factory.InitializingBean;


@Configuration
@ConditionalOnProperty(name = "shenyu.database.dialect", havingValue = "oceanbase")
static class OceanBaseSQLConfig implements InitializingBean {

/**
* Register auto dialect alias.
*/
@Override
public void afterPropertiesSet() {
PageAutoDialect.registerDialectAlias("oceanbase", MySqlDialect.class);
}
}

这里还需要额外配置yml

1
2
3
4
spring:
integration:
jdbc:
platform: mysql