当前位置:网站首页>Nacos adapts to oracle11g- modify the source code of Nacos
Nacos adapts to oracle11g- modify the source code of Nacos
2022-06-23 07:15:00 【qq_ thirty-seven million two hundred and seventy-nine thousand 】
nacos Only supported by default mysql database , To adapt oracle data source , You must modify the source code before compiling and deploying
One . The source code for
download nacos: link Source code , When the download is complete, switch the branch to feature_multiple_datasource_support
Two . jar Package introduction and replacement
Because this branch supports oracle12c, The driver package version needs to be changed
1.nacos-all Next pom File modification
<properties>
...
<!-- remove ojdbc8 Dependent version -->
<!-- <ojdbc.version>19.3.0.0</ojdbc.version>-->
<!-- change oracle Version is ojdbc7-->
<ojdbc.version>12.1.0.1.0</ojdbc.version>
...
</properties>
<!-- Manage dependent version numbers , Subprojects do not depend on... By default -->
<dependencyManagement>
<dependencies>
...
<!-- oracle package -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>${ojdbc.version}</version>
</dependency>
...
<!-- remove ojdbc8 Dependent version -->
<!-- <dependency>-->
<!-- <groupId>com.oracle.ojdbc</groupId>-->
<!-- <artifactId>ojdbc8</artifactId>-->
<!-- <version>${ojdbc.version}</version>-->
<!-- </dependency>-->
...
</dependencies>
</dependencyManagement>
2.nacos-config Of pom The file is added to introduce the database driver that needs to be supported , And cancel oracle High version driver is introduced
<!-- <dependency>-->
<!-- <groupId>com.oracle.ojdbc</groupId>-->
<!-- <artifactId>ojdbc8</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
</dependency>
3、 ... and . Logical modification of the primary key of the database mapping entity 【 It needs to be used with subsequent sequence statements 】
because mysql It uses a self increasing sequence ,oracle11g Does not support , So it's using jpa You need to specify the primary key and the name of the index used , The entity class needs to be modified
1. nacos-config Next
com.alibaba.nacos.config.server.modules.entity
Here is just one example , The blue part is modified 
It should be noted that PermissionsEntity Class resource Field , the reason being that oracle Database keywords , All statements in the table under construction ( Download table creation statement ) Modified as resources, You need to modify the corresponding fields
/**
* resource.
*/
@Column(name = "resources")
private String resource;
Four . modify nacos-console The configuration file application.properties
# oracle Database configuration
nacos.datasource.type=ORACLE
nacos.datasource.relational.dsList[0].url=jdbc:oracle:thin:@xxx:1521:orcl
nacos.datasource.relational.dsList[0].username=xxx
nacos.datasource.relational.dsList[0].password=xxx
nacos.datasource.relational.dsList[0].driver-class-name=oracle.jdbc.driver.OracleDriver
nacos.datasource.relational.dsList[0].hikari.connection-timeout=10000
nacos.datasource.relational.dsList[0].hikari.idle-timeout=120000
nacos.datasource.relational.dsList[0].hikari.max-lifetime=240000
nacos.datasource.relational.dsList[0].hikari.maximum-pool-size=20
nacos.datasource.relational.dsList[0].hikari.data-source-properties.cachePrepStmts=true
nacos.datasource.relational.dsList[0].hikari.data-source-properties.prepStmtCacheSize=250
nacos.datasource.relational.dsList[0].hikari.data-source-properties.prepStmtCacheSqlLimit=2048
nacos.datasource.relational.dsList[0].hikari.connection-test-query=SELECT 1 FROM dual
5、 ... and .idea Start the stand alone nacos debug
nacos-console Modular Nacos Start class 
Stand alone mode starts , environment variable -Dnacos.standalone=true
6、 ... and . Boot failure , No symbols found
If an error is reported and no symbol is found com.alibaba.nacos.consistency.entity
The simplest way is to execute mvn compile, The reason is that the package directory is made up of protobuf Automatically generated at compile time
Restart it
7、 ... and . Access page ,localhost:8848/nacos user / password :nacos/nacos

边栏推荐
- Mysql(十一) — MySQL面试题整理
- 313. 超级丑数
- How to achieve efficient network information dissemination
- Unet代码实现
- MySQL mvcc multi version concurrency control
- 897. incremental sequential search tree
- NTU-RGBD数据集下载及数据格式解析
- Nacos适配oracle11g-修改Nacos源码
- C # how to obtain DPI and real resolution (can solve the problem that has been 96)
- 318. 最大单词长度乘积
猜你喜欢

20BN-Jester完整数据集下载

产品-Axure9(英文版),原型设计 制作下拉二级菜单

Configuration and compilation of mingw-w64, msys and ffmpeg

Learning and using quartz scheduling framework

MySQL Niuke brush questions

C language learning summary

对二进制的某一位操作

406 double pointer (27. remove elements, 977. square of ordered array, 15. sum of three numbers, 18. sum of four numbers)

Nacos适配oracle11g-修改Nacos源码

GINet
随机推荐
U-Net: Convolutional Networks for Biomedical Image Segmentation
聚焦行业,赋能客户 | 博云容器云产品族五大行业解决方案发布
897. incremental sequential search tree
303. 区域和检索 - 数组不可变
codeforce 158B Taxi
900. RLE 迭代器
控制台程序
Nacos适配oracle11g-修改Nacos源码
312. 戳气球
316. 去除重复字母
Analysis of personalized learning progress in maker Education
Analyzing the creation principle in maker Education
In depth learning series 47:stylegan summary
细说Idea那些骚操作
【AI实战】XGBRegressor模型加速训练,使用GPU秒级训练XGBRegressor
407-栈与队列(232.用栈实现队列、225. 用队列实现栈)
PSP code implementation
yolov5检测小目标(附源码)
How to migrate virtual machines from VirtualBox to hype-v
npm下载报错npm ERR code ERESOLVE