源码连接: wanqiu/nacos-datasource-support
1、最外层pom.xml添加驱动:
<dependency><groupId>com.microsoft.sqlserver</groupId><artifactId>mssql-jdbc</artifactId><version>12.6.0.jre8</version>
</dependency>
2、[persistence]模块的pom文件添加驱动使用
<dependency><groupId>com.microsoft.sqlserver</groupId><artifactId>mssql-jdbc</artifactId>
</dependency>
3、将[plugin-datasource-sqlserver-plugin]代码复制到plugin下对应的路径下更新
4、修改[config]模块下的TenantCapacityPersistService.java文件
public TenantCapacity getTenantCapacity(String tenantId) {TenantCapacityMapper tenantCapacityMapper = mapperManager.findMapper(dataSourceService.getDataSourceType(),TableConstant.TENANT_CAPACITY);String sql = tenantCapacityMapper.select(Arrays.asList("id", "quota", "`usage`", "`max_size`", "max_aggr_count", "max_aggr_size", "tenant_id"),Collections.singletonList("tenant_id"));if (DataSourceConstant.SQLSERVER.equals(dataSourceService.getDataSourceType())) {sql = sql.replaceAll("`(\\w*)`", "[$1]");}List<TenantCapacity> list = jdbcTemplate.query(sql, new Object[] {tenantId}, TENANT_CAPACITY_ROW_MAPPER);if (list.isEmpty()) {return null;}return list.get(0);
}
5、修改[distribution]里面的数据库驱动:
spring.datasource.platform=sqlserver
db.pool.config.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
6、修改配置com.alibaba.nacos.plugin.datasource.mapper.Mapper
com.alibaba.nacos.plugin.datasource.impl.sqlserver.ConfigInfoAggrMapperBySqlserver
com.alibaba.nacos.plugin.datasource.impl.sqlserver.ConfigInfoBetaMapperBySqlserver
com.alibaba.nacos.plugin.datasource.impl.sqlserver.ConfigInfoMapperBySqlserver
com.alibaba.nacos.plugin.datasource.impl.sqlserver.ConfigInfoTagMapperBySqlserver
com.alibaba.nacos.plugin.datasource.impl.sqlserver.ConfigTagsRelationMapperBySqlserver
com.alibaba.nacos.plugin.datasource.impl.sqlserver.HistoryConfigInfoMapperBySqlserver
com.alibaba.nacos.plugin.datasource.impl.sqlserver.TenantInfoMapperBySqlserver
com.alibaba.nacos.plugin.datasource.impl.sqlserver.TenantCapacityMapperBySqlserver
com.alibaba.nacos.plugin.datasource.impl.sqlserver.GroupCapacityMapperBySqlserver