提交 70d0eaca 编辑于 作者: 夏东伟's avatar 夏东伟
浏览文件

SQLserver数据源配置

上级 75351615
加载中
加载中
加载中
加载中
+29 −10
原始行号 原始行 差异行号 差异行
@@ -26,4 +26,23 @@ public class DataSourceConfig {
        }
        }
        return dataSource;
        return dataSource;
    }
    }

    @Bean
    @ConfigurationProperties(prefix = "sqlserver")
    DataSource sqlserverDatasource() {
        return DataSourceBuilder.create().build();
    }

    @Bean
    JdbcTemplate sqlserverJdbcTemplate(JdbcProperties properties) {
        JdbcTemplate jdbcTemplate = new JdbcTemplate(sqlserverDatasource());
        JdbcProperties.Template template = properties.getTemplate();
        jdbcTemplate.setFetchSize(template.getFetchSize());
        jdbcTemplate.setMaxRows(template.getMaxRows());
        if (template.getQueryTimeout() != null) {
            jdbcTemplate.setQueryTimeout((int) template.getQueryTimeout().getSeconds());
        }
        return jdbcTemplate;
    }

}
}
+24 −0
原始行号 原始行 差异行号 差异行
spring.profiles.include=mybatis,quartz,swagger,security

# Mysql
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/zhongtong_dev?useSSL=false&useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=123456

# redis
spring.redis.host=10.100.172.102
spring.redis.port=6379
spring.redis.password=

# sql server
#spring.datasource.sqlserver.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
##spring.datasource.sqlserver.jdbc-url=jdbc:sqlserver://127.0.0.1:1433;DatabaseName=CARTEST_ZTKC
##spring.datasource.sqlserver.username=admin
##spring.datasource.sqlserver.password=123456

# secondary datasource (MS SQL Server)
sqlserver.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
sqlserver.jdbc-url=jdbc:sqlserver://127.0.0.1:1433;DatabaseName=CARTEST_ZTKC
sqlserver.username=admin
sqlserver.password=123456
 No newline at end of file