Commit 70d0eaca authored by 夏东伟's avatar 夏东伟

SQLserver数据源配置

parent 75351615
...@@ -26,4 +26,23 @@ public class DataSourceConfig { ...@@ -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;
}
} }
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment