blob: 571908bed4b2959402e97fc3539db17ce0693865 [file] [log] [blame]
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Spring 命名空间 on ShardingSphere</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/spring-namespace/</link>
<description>Recent content in Spring 命名空间 on ShardingSphere</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language>
<atom:link href="https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/spring-namespace/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>模式配置</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/spring-namespace/mode/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/spring-namespace/mode/</guid>
<description>背景信息 缺省配置为使用单机模式。
参数解释 单机模式 命名空间:http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/standalone/repository-5.1.1.xsd
&amp;lt;standalone:repository /&amp;gt;
名称 类型 说明 id 属性 持久化仓库 Bean 名称 type 属性 持久化仓库类型 props (?) 标签 持久化仓库所需属性 集群模式 (推荐) 命名空间:http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/cluster/repository-5.1.1.xsd
&amp;lt;cluster:repository /&amp;gt;
名称 类型 说明 id 属性 持久化仓库 Bean 名称 type 属性 持久化仓库类型 namespace 属性 注册中心命名空间 server-lists 属性 注册中心连接地址 props (?</description>
</item>
<item>
<title>数据源配置</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/spring-namespace/data-source/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/spring-namespace/data-source/</guid>
<description>背景信息 任何配置成为 Spring Bean 的数据源对象即可与 ShardingSphere-JDBC 的 Spring 命名空间配合使用。
配置示例的数据库驱动为 MySQL,连接池为 HikariCP,可以更换为其他数据库驱动和连接池。 当使用 ShardingSphere JDBC 时,JDBC 池的属性名取决于各自 JDBC 池自己的定义,并不由 ShardingSphere 硬定义,相关的处理可以参考类org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCreator。例如对于 Alibaba Druid 1.2.9 而言,使用url代替如下示例中的jdbcUrl是预期行为。
操作步骤 1. 引入 MAVEN 依赖 &amp;lt;dependency&amp;gt; &amp;lt;groupId&amp;gt;org.apache.shardingsphere&amp;lt;/groupId&amp;gt; &amp;lt;artifactId&amp;gt;shardingsphere-jdbc-core-spring-namespace&amp;lt;/artifactId&amp;gt; &amp;lt;version&amp;gt;${latest.release.version}&amp;lt;/version&amp;gt; &amp;lt;/dependency&amp;gt; 注意:请将 ${latest.release.version} 更改为实际的版本号。
配置示例 &amp;lt;beans xmlns=&amp;#34;http://www.springframework.org/schema/beans&amp;#34; xmlns:xsi=&amp;#34;http://www.w3.org/2001/XMLSchema-instance&amp;#34; xmlns:shardingsphere=&amp;#34;http://shardingsphere.apache.org/schema/shardingsphere/datasource&amp;#34; xsi:schemaLocation=&amp;#34;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://shardingsphere.apache.org/schema/shardingsphere/datasource http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd &amp;#34;&amp;gt; &amp;lt;bean id=&amp;#34;ds1&amp;#34; class=&amp;#34;com.zaxxer.hikari.HikariDataSource&amp;#34; destroy-method=&amp;#34;close&amp;#34;&amp;gt; &amp;lt;property name=&amp;#34;driverClassName&amp;#34; value=&amp;#34;com.mysql.jdbc.Driver&amp;#34; /&amp;gt; &amp;lt;property name=&amp;#34;jdbcUrl&amp;#34; value=&amp;#34;jdbc:mysql://localhost:3306/ds1&amp;#34; /&amp;gt; &amp;lt;property name=&amp;#34;username&amp;#34; value=&amp;#34;root&amp;#34; /&amp;gt; &amp;lt;property name=&amp;#34;password&amp;#34; value=&amp;#34;&amp;#34; /&amp;gt; &amp;lt;/bean&amp;gt; &amp;lt;bean id=&amp;#34;ds2&amp;#34; class=&amp;#34;com.</description>
</item>
<item>
<title>算法配置</title>
<link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/spring-namespace/algorithm/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/spring-namespace/algorithm/</guid>
<description>分片算法 &amp;lt;!-- algorithmName 由用户指定,需要和分片策略中的 algorithm-ref 属性一致 --&amp;gt; &amp;lt;!-- type 和 props,请参考分片内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/sharding/ --&amp;gt; &amp;lt;sharding:sharding-algorithm id=&amp;#34;algorithmName&amp;#34; type=&amp;#34;xxx&amp;#34;&amp;gt; &amp;lt;props&amp;gt; &amp;lt;prop key=&amp;#34;xxx&amp;#34;&amp;gt;xxx&amp;lt;/prop&amp;gt; &amp;lt;/props&amp;gt; &amp;lt;/sharding:sharding-algorithm&amp;gt; 加密算法 &amp;lt;!-- encryptorName 由用户指定,需要和加密规则中的 encrypt-algorithm-ref 属性一致 --&amp;gt; &amp;lt;!-- type 和 props,请参考加密内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/encrypt/ --&amp;gt; &amp;lt;encrypt:encrypt-algorithm id=&amp;#34;encryptorName&amp;#34; type=&amp;#34;xxx&amp;#34;&amp;gt; &amp;lt;props&amp;gt; &amp;lt;prop key=&amp;#34;xxx&amp;#34;&amp;gt;xxx&amp;lt;/prop&amp;gt; &amp;lt;/props&amp;gt; &amp;lt;/encrypt:encrypt-algorithm&amp;gt; 读写分离负载均衡算法 &amp;lt;!-- loadBalancerName 由用户指定,需要和读写分离规则中的 load-balance-algorithm-ref 属性一致 --&amp;gt; &amp;lt;!-- type 和 props,请参考读写分离负载均衡内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/load-balance/ --&amp;gt; &amp;lt;readwrite-splitting:load-balance-algorithm id=&amp;#34;loadBalancerName&amp;#34; type=&amp;#34;xxx&amp;#34;&amp;gt; &amp;lt;props&amp;gt; &amp;lt;prop key=&amp;#34;xxx&amp;#34;&amp;gt;xxx&amp;lt;/prop&amp;gt; &amp;lt;/props&amp;gt; &amp;lt;/readwrite-splitting:load-balance-algorithm&amp;gt; 影子算法 &amp;lt;!-- shadowAlgorithmName 由用户指定,需要和影子库则中的 shadow-algorithm-ref 属性一致 --&amp;gt; &amp;lt;!-- type 和 props,请参考影子库内置算法:https://shardingsphere.</description>
</item>
</channel>
</rss>