点击查看【bilibili】
Nacos 从 2.2.0 版本开始,可通过 SPI 机制注入多数据源实现插件,并在引入对应数据源实现后,便可在 Nacos 启动时通过读取 application.properties 配置文件中 spring.datasource.platform 配置项选择加载对应多数据源插件.

Nacos 官方默认实现 MySQL、Derby ,其他类型数据库接入需要参考下文自己扩展。

自定义 oracle 插件
1. 添加 oracle 插件
依赖已上传 maven 中央仓库,请勿使用阿里云代理
<dependency><groupId>com.pig4cloud.plugin</groupId><artifactId>nacos-datasource-plugin-oracle</artifactId><version>0.0.1</version></dependency><dependency><groupId>com.oracle.database.jdbc</groupId><artifactId>ojdbc8</artifactId><version>21.3.0.0</version></dependency>
2. 导入 nacos oracle 数据库脚本
3. 配置 nacos 数据源链接信息
db:num: 1user: PIGXpassword: PIGXurl: jdbc:oracle:thin:@172.16.1.198:1521:XEpool.config.driver-class-name: oracle.jdbc.OracleDriverpool.config.connection-test-query: 'SELECT 1 FROM DUAL'
4. 指定 nacos 数据源平台
spring:datasource:platform: oracle

源码地址: https://github.com/pig-mesh/nacos-datasource-plugin-oracle 插件加入到 pig-register 即可使用
https://github.com/pig-mesh/pig 点击Star关注更新,基于 Spring Cloud 2022 、Spring Boot 3、 Spring Authorization Server 的微服务平台
