备忘&分享
properties文件
示例2个数据源resourcesA & resourcesB
# web port
server.port=8102
# no web
#spring.main.web-environment=false
# log config
logging.config=classpath:logback.xml
spring.devtools.restart.exclude=static/**,public/**
spring.devtools.restart.enabled=true
#resourcesA
spring.datasource.adas.resourcesA.minimum-idle=5
spring.datasource.adas.resourcesA.maximum-pool-size=10
spring.datasource.adas.resourcesA.idle-timeout=30000
spring.datasource.adas.resourcesA.connection-timeout=30000
spring.datasource.adas.resourcesA.ConnectionTestQuery=select 1
spring.datasource.adas.resourcesA.jdbcUrl=jdbc:postgresql://******此处是数据库链接
spring.datasource.adas.resourcesA.username=postgres
spring.datasource.adas.resourcesA.password=password
#resourcesB
spring.datasource.empdata.resourcesB.minimum-idle=5
spring.datasource.empdata.resourcesB.maximum-pool-size=10
spring.datasource.empdata.resourcesB.idle-timeout=30000
spring.datasource.empdata.resourcesB.connection-timeout=30000
spring.datasource.empdata.resourcesB.ConnectionTestQuery=select 1
spring.datasource.empdata.resourcesB.jdbcUrl=jdbc:postgresql://***********此处是数据库链接
spring.datasource.empdata.resourcesB.username=postgres
spring.datasource.empdata.resourcesB.password=password
JAVA配置数据源
resourcesA
import javax.sql.DataSource;
import org.apache.ibatis.io.VFS;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.mybatis.spring.boot.autoconfigure.SpringBootVFS;
import org.springframework