当前位置:网站首页>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

边栏推荐
猜你喜欢

Traversal of binary tree and related knowledge

TensorFlow中的数据类型

PSP代码实现

深度学习系列47:超分模型Real-ESRGAN

正则表达式图文超详细总结不用死记硬背(上篇)

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

GloRe

TP6+Redis+think-queue+Supervisor实现进程常驻消息队列/job任务

Flannel 工作原理

闫氏DP分析法
随机推荐
【***数组***】
GloRe
如何在 PHP 中进行日期格式验证检查(正则)
‘latin-1‘ codec can‘t encode characters in position 103-115: Body (‘一串中文‘) is not valid Latin-1
303. 区域和检索 - 数组不可变
899. 有序队列
303. region and retrieval - array immutable
How to achieve efficient network information dissemination
Database principle experiment test questions, about book classification table
Specific help of OSI layered model to work
In depth learning series 47:stylegan summary
Tp6+redis+think-queue+supervisor implements the process resident message queue /job task
GIS实战应用案例100篇(七十九)-多规整合底图的制作要点
聚焦行业,赋能客户 | 博云容器云产品族五大行业解决方案发布
用户态和内核态
1161 Merging Linked Lists
NPM download error NPM err code error
[system] right click the desktop icon. After turning around, the Explorer will crash and the desktop will be refreshed
char和varchar区别
897. 递增顺序搜索树