不可乘快而多事,不可因倦而鲜终。——菜根谭
首先docker
跑一个实例
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
引入依赖:
<dependency>
<groupId>com.oceanbase</groupId>
<artifactId>oceanbase-client</artifactId>
<version>${oceanbase.version}</version>
</dependency>
版本是<oceanbase.version>2.4.12</oceanbase.version>
这边主要是需要注册pagehelper
的方言:
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
spring:
integration:
jdbc:
platform: mysql