springboot 配置了双数据源mysql和sqlserver,怎么只让mysql创建表sqlserver不自动创建表
1个回答
展开全部
首先是properties配置
当然mysql 和 sqlserver的jar包要加上。
#mysql
spring.datasource.primary.url=jdbc:mysql://localhost:3306/db_company?useUnicode=true&characterEncoding=utf-8
spring.datasource.primary.username = root
spring.datasource.primary.password = 123456
spring.datasource.primary.driverClassName = com.mysql.jdbc.Driver
spring.datasource.primary.max-active=20
spring.datasource.primary.max-idle=8
spring.datasource.primary.max-maxWait=100
spring.datasource.primary.min-idle=8
spring.datasource.primary.initial-size=10
#sqlserver
spring.datasource.second.url=jdbc:sqlserver://192.168.x.xxx:1433;database=QSTMGood
spring.datasource.second.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.second.username=sa
spring.datasource.second.password=baitu123
spring.datasource.second.initialSize=1
spring.datasource.second.minIdle=1
spring.datasource.second.maxActive=20
spring.datasource.second.maxWait=30000
spring.datasource.second.timeBetweenEvictionRunsMillis=40000
spring.datasource.second.minEvictableIdleTimeMillis=300000
接下来是jdbctemplate的设置
当然mysql 和 sqlserver的jar包要加上。
#mysql
spring.datasource.primary.url=jdbc:mysql://localhost:3306/db_company?useUnicode=true&characterEncoding=utf-8
spring.datasource.primary.username = root
spring.datasource.primary.password = 123456
spring.datasource.primary.driverClassName = com.mysql.jdbc.Driver
spring.datasource.primary.max-active=20
spring.datasource.primary.max-idle=8
spring.datasource.primary.max-maxWait=100
spring.datasource.primary.min-idle=8
spring.datasource.primary.initial-size=10
#sqlserver
spring.datasource.second.url=jdbc:sqlserver://192.168.x.xxx:1433;database=QSTMGood
spring.datasource.second.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.datasource.second.username=sa
spring.datasource.second.password=baitu123
spring.datasource.second.initialSize=1
spring.datasource.second.minIdle=1
spring.datasource.second.maxActive=20
spring.datasource.second.maxWait=30000
spring.datasource.second.timeBetweenEvictionRunsMillis=40000
spring.datasource.second.minEvictableIdleTimeMillis=300000
接下来是jdbctemplate的设置
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询