1、实现mybatis-plus的多个数据库的切换方式
源码地址:https://github.com/baomidou/mybatisplus-spring-mvc
2、因为其文档都是相互依赖的,所以修改配置,就是在已有的配置中修改
这里配置多数据源采用定义不同的profile方式修改启动时连接的数据库
原版
配置文件位置:https://github.com/baomidou/mybatisplus-spring-mvc/tree/master/src/main/resources/spring
1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xmlns:context="http://www.springframework.org/schema/context" xmlns:util="http://www.springframework.org/schema/util" 5 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd"> 6 7 <!-- 引入属性文件 --> 8 <context:property-placeholder location="classpath:config.properties"/> 9 10 <!-- Service包(自动注入) --> 11 <context:component-scan base-package="com.baomidou.springmvc.service"/> 12 13 <import resource="classpath:spring/spring-mybatis.xml"/> 14 </beans>