项目结构
application.yml
spring:
profiles:
active: prd
application-prd.yml
spring:
datasource:
test1:
driver-class-name: com.mysql.jdbc.Driver
username: ****
password: ****
jdbc-url: jdbc:mysql://192.168.5.155:3306/test01?characterEncoding=UTF-8
test2:
driver-class-name: com.mysql.jdbc.Driver
username: ****
password: ****
jdbc-url: jdbc:mysql://192.168.5.155:3306/test02?characterEncoding=UTF-8
mybatis:
#映射实体位置
#如果mapper.xml放在resources中可以生效
#如果mapper.xml放在dao接口的包中不生效
type-aliases-package: cn.***.pojo
#如果mapper.xml文件放在resources中需要下面这行配置,如果和dao接口放在一个包中不需要
# mapper-locations: classpath:mybatis/mapper/*.xml
TestDataSource1
如果mapper.xml文件放在和dao一个包中一定要加入bean.setTypeAliasesPackage("cn.***.pojo"),不然映射不到实体