1、nacos源码 地址:https://github.com/alibaba/nacos/releases/tag/1.4.1 2、修改主pom.xml
引入dm包
3、修改console下的配置文件
spring.datasource.platform=dm
### Count of DB:
db.num=1
db.jdbcDriverName=dm.jdbc.driver.DmDriver
### Connect URL of DB:
db.url.0=jdbc:dm://ip:5236/NACOS_CONFIG?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=username
db.password.0=password
4、修改代码config下的ExternalDataSourceProperties.class 修改如下:
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);
poolProperties.setDriverClassName(JDBC_DRIVER_NAME);
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();
ds.setConnectionTestQuery(TEST_QUERY);
ds.setIdleTimeout(TimeUnit.MINUTES.toMillis(10L));
ds.setConnectionTimeout(TimeUnit.SECONDS.toMillis(3L));
System.out.println("#################################");
System.out.println("jdbcDriverName=" + jdbcDriverName);
if (StringUtils.isNotEmpty(jdbcDriverName)) {
ds.setDriverClassName(jdbcDriverName);
} else {
ds.setDriverClassName(JDBC_DRIVER_NAME);
}
System.out.println("#################################");
System.out.println("dataSources=" + dataSources);
dataSources.add(ds);
callback.accept(ds);
}
Preconditions.checkArgument(CollectionUtils.isNotEmpty(dataSources), "no datasource available");
return dataSources;
}
5、修改对应实现类ExternalDataSourceServiceImpl.class 将所有的sql语句加上模式名称,如下 6、生成部署文件 执行语句
mvn -Prelease-nacos -Dmaven.test.skip=true -Dpmd.skip=true -Dcheckstyle.skip=true clean install -U
7、目标文件位置
distribution/target/nacos-server-$version 下的 nacos 文件夹 就是最终的输出物
8、启动 启动 nacos,bin文件夹下 sh startup.sh -m standalone查看启动日志 tail -f 支持达梦改造后的Nacos/nacos/logs/start.out
9、登录 http://ip:8848/nacos/index.html
|