美文网首页
ssm中配合druid连接池使用sharding-sphere的

ssm中配合druid连接池使用sharding-sphere的

作者: loquito | 来源:发表于2020-03-11 22:05 被阅读0次

pom中加依赖

<dependency>

<groupId>org.apache.shardingsphere</groupId>

<artifactId>sharding-jdbc-core</artifactId>

<version>4.0.1</version>

</dependency>

<dependency>

<groupId>org.apache.shardingsphere</groupId>

<artifactId>sharding-jdbc-spring-namespace</artifactId>

<version>4.0.1</version>

</dependency>

不加第二个依赖的话,在spring的配置中就找不到命名空间,官网没写这个依赖,但是要加、

官方文档链接在这里,https://shardingsphere.apache.org/document/current/cn/manual/sharding-jdbc/usage/read-write-splitting/

需要修改的是连接池从dbcp到druid

连接池改成druid

剩下的就和文档的一样就行。

接着把数据源修改到这边

<!-- 配置事务管理器 -->

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

<property name="dataSource" ref="masterSlaveDataSource" />

</bean>

结束。

相关文章

网友评论

      本文标题:ssm中配合druid连接池使用sharding-sphere的

      本文链接:https://www.haomeiwen.com/subject/fjdkjhtx.html