Nacos 支持Oracle數(shù)據(jù)庫(kù)持久化插件使用
Nacos 從 2.2.0 版本開(kāi)始,可通過(guò) SPI 機(jī)制注入多數(shù)據(jù)源實(shí)現(xiàn)插件,并在引入對(duì)應(yīng)數(shù)據(jù)源實(shí)現(xiàn)后,便可在 Nacos 啟動(dòng)時(shí)通過(guò)讀取 application.properties 配置文件中 spring.datasource.platform 配置項(xiàng)選擇加載對(duì)應(yīng)多數(shù)據(jù)源插件.
“Nacos 官方默認(rèn)實(shí)現(xiàn) MySQL、Derby ,其他類型數(shù)據(jù)庫(kù)接入需要參考下文自己擴(kuò)展。
自定義 oracle 插件
1. 添加 oracle 插件
“依賴已上傳 maven 中央倉(cāng)庫(kù),請(qǐng)勿使用阿里云代理
<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. 導(dǎo)入 nacos oracle 數(shù)據(jù)庫(kù)腳本
點(diǎn)擊下載 nacos oracle 腳本[1]
3. 配置 nacos 數(shù)據(jù)源鏈接信息
db:
num: 1
user: PIGX
password: PIGX
url: jdbc:oracle:thin:@172.16.1.198:1521:XE
pool.config.driver-class-name: oracle.jdbc.OracleDriver
pool.config.connection-test-query: 'SELECT 1 FROM DUAL'
4. 指定 nacos 數(shù)據(jù)源平臺(tái)
spring:
datasource:
platform: oracle
參考資料
點(diǎn)擊下載 nacos oracle 腳本:https://github.com/pig-mesh/nacos-datasource-plugin-oracle/tree/master/sql
2022-12-19


加群一塊學(xué)習(xí)nacos2.2
評(píng)論
圖片
表情
