| <?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 |
| &lt;standalone:repository /&gt; |
| 名称 类型 说明 id 属性 持久化仓库 Bean 名称 type 属性 持久化仓库类型 props (?) 标签 持久化仓库所需属性 集群模式 (推荐) 命名空间:http://shardingsphere.apache.org/schema/shardingsphere/mode-repository/cluster/repository-5.1.1.xsd |
| &lt;cluster:repository /&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 依赖 &lt;dependency&gt; &lt;groupId&gt;org.apache.shardingsphere&lt;/groupId&gt; &lt;artifactId&gt;shardingsphere-jdbc-core-spring-namespace&lt;/artifactId&gt; &lt;version&gt;${latest.release.version}&lt;/version&gt; &lt;/dependency&gt; 注意:请将 ${latest.release.version} 更改为实际的版本号。 |
| 配置示例 &lt;beans xmlns=&#34;http://www.springframework.org/schema/beans&#34; xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34; xmlns:shardingsphere=&#34;http://shardingsphere.apache.org/schema/shardingsphere/datasource&#34; xsi:schemaLocation=&#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 &#34;&gt; &lt;bean id=&#34;ds1&#34; class=&#34;com.zaxxer.hikari.HikariDataSource&#34; destroy-method=&#34;close&#34;&gt; &lt;property name=&#34;driverClassName&#34; value=&#34;com.mysql.jdbc.Driver&#34; /&gt; &lt;property name=&#34;jdbcUrl&#34; value=&#34;jdbc:mysql://localhost:3306/ds1&#34; /&gt; &lt;property name=&#34;username&#34; value=&#34;root&#34; /&gt; &lt;property name=&#34;password&#34; value=&#34;&#34; /&gt; &lt;/bean&gt; &lt;bean id=&#34;ds2&#34; class=&#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>分片算法 &lt;!-- algorithmName 由用户指定,需要和分片策略中的 algorithm-ref 属性一致 --&gt; &lt;!-- type 和 props,请参考分片内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/sharding/ --&gt; &lt;sharding:sharding-algorithm id=&#34;algorithmName&#34; type=&#34;xxx&#34;&gt; &lt;props&gt; &lt;prop key=&#34;xxx&#34;&gt;xxx&lt;/prop&gt; &lt;/props&gt; &lt;/sharding:sharding-algorithm&gt; 加密算法 &lt;!-- encryptorName 由用户指定,需要和加密规则中的 encrypt-algorithm-ref 属性一致 --&gt; &lt;!-- type 和 props,请参考加密内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/encrypt/ --&gt; &lt;encrypt:encrypt-algorithm id=&#34;encryptorName&#34; type=&#34;xxx&#34;&gt; &lt;props&gt; &lt;prop key=&#34;xxx&#34;&gt;xxx&lt;/prop&gt; &lt;/props&gt; &lt;/encrypt:encrypt-algorithm&gt; 读写分离负载均衡算法 &lt;!-- loadBalancerName 由用户指定,需要和读写分离规则中的 load-balance-algorithm-ref 属性一致 --&gt; &lt;!-- type 和 props,请参考读写分离负载均衡内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/load-balance/ --&gt; &lt;readwrite-splitting:load-balance-algorithm id=&#34;loadBalancerName&#34; type=&#34;xxx&#34;&gt; &lt;props&gt; &lt;prop key=&#34;xxx&#34;&gt;xxx&lt;/prop&gt; &lt;/props&gt; &lt;/readwrite-splitting:load-balance-algorithm&gt; 影子算法 &lt;!-- shadowAlgorithmName 由用户指定,需要和影子库则中的 shadow-algorithm-ref 属性一致 --&gt; &lt;!-- type 和 props,请参考影子库内置算法:https://shardingsphere.</description> |
| </item> |
| |
| </channel> |
| </rss> |