官网文档没有相关的说明,所以费了些劲,但是确实很简单,发出来,希望能帮助到有需要的人
<bean id="jade.dataSource.cn.bestmk.dao1"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url"
value="jdbc:mysql://localhost:3306/db1?useSSL=true&useUnicode=true&character_set_server=utf8mb4"/>
<property name="username" value="bestmk"/>
<property name="password" value="bestmk.cn"/>
</bean>
<bean id="jade.dataSource.cn.bestmk.dao1"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url"
value="jdbc:mysql://localhost:3306/db2?useSSL=true&useUnicode=true&character_set_server=utf8mb4"/>
<property name="username" value="bestmk"/>
<property name="password" value="bestmk.cn"/>
</bean>
如上配置代码,配置多个数据源只需要将不同数据源的dao放在不同的package目录中,例如cn.bestmk.dao1
,cn.bestmk.dao2