https://github.com/alibaba/nacos
8.1
com.dm.driver
jdbc18
${dm-driver.version}
如果编译失败可以降低以下版本
com.dm.driver
jdbc18
#*************** Config Module Related Configurations ***************#
### If use MySQL as datasource:
spring.datasource.platform=dm
### Count of DB:
db.num=1
### Connect URL of DB:
db.jdbcDriverName=dm.jdbc.driver.DmDriver
db.url.0=jdbc:dm://127.0.0.1:5236/MAIN?STU&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8
db.user.0=NACOS
db.password.0=NACOS!@#
修改ExternalDataSourceProperties.java
private String jdbcDriverName;
public String getJdbcDriverName() {
return jdbcDriverName;
}
public void setJdbcDriverName(String jdbcDriverName) {
this.jdbcDriverName = jdbcDriverName;
}
List<HikariDataSource> build(Environment environment, Callback<HikariDataSource> callback) {
List<HikariDataSource> dataSources = new ArrayList<>();
Binder.get(environment).bind("db", Bindable.ofInstance(this));
Preconditions.checkArgument(Objects.nonNull(num), "db.num is null");
Preconditions.checkArgument(CollectionUtils.isNotEmpty(user), "db.user or db.user.[index] is null");
Preconditions.checkArgument(CollectionUtils.isNotEmpty(password), "db.password or db.password.[index] is null");
for (int index = 0; index < num; index++) {
int currentSize = index + 1;
Preconditions.checkArgument(url.size() >= currentSize, "db.url.%s is null", index);
DataSourcePoolProperties poolProperties = DataSourcePoolProperties.build(environment);
if (StringUtils.isEmpty(poolProperties.getDataSource().getDriverClassName())) {
//poolProperties.setDriverClassName(JDBC_DRIVER_NAME);
System.out.println("===================================");
System.out.println("jdbcDriverName=" + jdbcDriverName);
if (StringUtils.isNotEmpty(jdbcDriverName)) {
// 增加其他数据库驱动的支持
poolProperties.setDriverClassName(jdbcDriverName);
} else {
//默认使用mysql驱动
poolProperties.setDriverClassName(JDBC_DRIVER_NAME);
}
System.out.println("===================================");
System.out.println("dataSources=" + dataSources);
}
poolProperties.setJdbcUrl(url.get(index).trim());
poolProperties.setUsername(getOrDefault(user, index, user.get(0)).trim());
poolProperties.setPassword(getOrDefault(password, index, password.get(0)).trim());
HikariDataSource ds = poolProperties.getDataSource();
if (StringUtils.isEmpty(ds.getConnectionTestQuery())) {
ds.setConnectionTestQuery(TEST_QUERY);
}
dataSources.add(ds);
callback.accept(ds);
}
Preconditions.checkArgument(CollectionUtils.isNotEmpty(dataSources), "no datasource available");
return dataSources;
}
修改DataSourceConstant.java
//新增达梦常量
public static final String DM = "dm";
修改ExternalConfigInfoPersistServiceImpl.java
176行、194行异常DuplicateKeyException改成DataIntegrityViolationException(不然编辑yml文件时会报)
try {
addConfigInfo(srcIp, srcUser, configInfo, time, configAdvanceInfo, notify);
} catch (DataIntegrityViolationException ive) { // Unique constraint conflict
updateConfigInfo(configInfo, srcIp, srcUser, time, configAdvanceInfo, notify);
}
Map<String, Object> configAdvanceInfo, boolean notify) {
try {
addConfigInfo(srcIp, srcUser, configInfo, time, configAdvanceInfo, notify);
return true;
} catch (DataIntegrityViolationException ignore) { // Unique constraint conflict
return updateConfigInfoCas(configInfo, srcIp, srcUser, time, configAdvanceInfo, notify);
}
DataSourceConstant类添加常量
内容拷贝了mysql包下类,改了类名,每个类里面 DataSourceConstant.DM
com.alibaba.nacos.plugin.datasource.mapper.Mapper文件添加上图所加的达梦实现类路径
idea运行单机版需要添加VM options配置:-Dnacos.standalone=true,nacos-console直接springboot run就可以,打包部署到服务器:
配了maven环境变量,打开nacos项目根目录,执行命令:mvn -Prelease-nacos ‘-Dmaven.test.skip=true’ ‘-Dcheckstyle.skip=true’ clean install -U 在nacos-distribution/target/目录下有nacos-server-2.1.1.tar.gz文件,单机启动需要添加参数用-m standalone,用start.sh启动命令:./startup.sh -m standalone 用jar启动命令:java ‘-Dnacos.standalone=true’ -jar ./nacos-server.jar;