| <?xml version="1.0" encoding="utf-8" standalone="yes"?> |
| <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> |
| <channel> |
| <title>Spring Boot Starter on ShardingSphere</title> |
| <link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/spring-boot-starter/</link> |
| <description>Recent content in Spring Boot Starter 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-boot-starter/index.xml" rel="self" type="application/rss+xml" /> |
| |
| |
| <item> |
| <title>模式配置</title> |
| <link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/spring-boot-starter/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-boot-starter/mode/</guid> |
| <description>参数解释 spring.shardingsphere.mode.type= # 运行模式类型。可选配置:Standalone、Cluster spring.shardingsphere.mode.repository= # 持久化仓库配置。Memory 类型无需持久化 spring.shardingsphere.mode.overwrite= # 是否使用本地配置覆盖持久化配置 单机模式 spring.shardingsphere.mode.type=Standalone spring.shardingsphere.mode.repository.type= # 持久化仓库类型 spring.shardingsphere.mode.repository.props.&lt;key&gt;= # 持久化仓库所需属性 spring.shardingsphere.mode.overwrite= # 是否使用本地配置覆盖持久化配置 集群模式 (推荐) spring.shardingsphere.mode.type=Cluster spring.shardingsphere.mode.repository.type= # 持久化仓库类型 spring.shardingsphere.mode.repository.props.namespace= # 注册中心命名空间 spring.shardingsphere.mode.repository.props.server-lists= # 注册中心连接地址 spring.shardingsphere.mode.repository.props.&lt;key&gt;= # 持久化仓库所需属性 spring.shardingsphere.mode.overwrite= # 是否使用本地配置覆盖持久化配置 注意事项 生产环境建议使用集群模式部署。 集群模式部署推荐使用 ZooKeeper 注册中心。 操作步骤 引入 MAVEN 依赖 &lt;dependency&gt; &lt;groupId&gt;org.apache.shardingsphere&lt;/groupId&gt; &lt;artifactId&gt;shardingsphere-jdbc-core-spring-boot-starter&lt;/artifactId&gt; &lt;version&gt;${latest.release.version}&lt;/version&gt; &lt;/dependency&gt; 注意:请将 ${latest.release.version} 更改为实际的版本号。 |
| 配置示例 单机模式 spring.shardingsphere.mode.type=Standalone spring.shardingsphere.mode.repository.type=File spring.shardingsphere.mode.repository.props.path=.shardingsphere spring.shardingsphere.mode.overwrite=false 集群模式 (推荐) spring.shardingsphere.mode.type=Cluster spring.</description> |
| </item> |
| |
| <item> |
| <title>数据源配置</title> |
| <link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/spring-boot-starter/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-boot-starter/data-source/</guid> |
| <description>背景信息 使用本地数据源 示例的数据库驱动为 MySQL,连接池为 HikariCP,可以更换为其他数据库驱动和连接池。当使用 ShardingSphere JDBC 时,JDBC 池的属性名取决于各自 JDBC 池自己的定义,并不由 ShardingSphere 硬定义,相关的处理可以参考类org.apache.shardingsphere.infra.datasource.pool.creator.DataSourcePoolCreator。例如对于 Alibaba Druid 1.2.9 而言,使用url代替如下示例中的jdbc-url是预期行为。 |
| 使用 JNDI 数据源 如果计划使用 JNDI 配置数据库,在应用容器(如 Tomcat)中使用 ShardingSphere-JDBC 时, 可使用 spring.shardingsphere.datasource.${datasourceName}.jndiName 来代替数据源的一系列配置。 |
| 参数解释 使用本地数据源 spring.shardingsphere.datasource.names= # 真实数据源名称,多个数据源用逗号区分 # &lt;actual-data-source-name&gt; 表示真实数据源名称 spring.shardingsphere.datasource.&lt;actual-data-source-name&gt;.type= # 数据库连接池全类名 spring.shardingsphere.datasource.&lt;actual-data-source-name&gt;.driver-class-name= # 数据库驱动类名,以数据库连接池自身配置为准 spring.shardingsphere.datasource.&lt;actual-data-source-name&gt;.jdbc-url= # 数据库 URL 连接,以数据库连接池自身配置为准 spring.shardingsphere.datasource.&lt;actual-data-source-name&gt;.username= # 数据库用户名,以数据库连接池自身配置为准 spring.shardingsphere.datasource.&lt;actual-data-source-name&gt;.password= # 数据库密码,以数据库连接池自身配置为准 spring.shardingsphere.datasource.&lt;actual-data-source-name&gt;.&lt;xxx&gt;= # ... 数据库连接池的其它属性 使用 JNDI 数据源 spring.shardingsphere.datasource.names= # 真实数据源名称,多个数据源用逗号区分 # &lt;actual-data-source-name&gt; 表示真实数据源名称 spring.shardingsphere.datasource.&lt;actual-data-source-name&gt;.jndi-name= # 数据源 JNDI 操作步骤 1.</description> |
| </item> |
| |
| <item> |
| <title>算法配置</title> |
| <link>https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/spring-boot-starter/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-boot-starter/algorithm/</guid> |
| <description>分片算法 # sharding-algorithm-name 由用户指定,需要和分片策略中的 sharding-algorithm-name 属性一致 # type 和 props,请参考分片内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/sharding/ spring.shardingsphere.rules.sharding.sharding-algorithms.&lt;sharding-algorithm-name&gt;.type=xxx spring.shardingsphere.rules.sharding.sharding-algorithms.&lt;sharding-algorithm-name&gt;.props.xxx=xxx 加密算法 # encrypt-algorithm-name 由用户指定,需要和加密规则中的 encryptor-name 属性一致 # type 和 props,请参考加密内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/encrypt/ spring.shardingsphere.rules.encrypt.encryptors.&lt;encrypt-algorithm-name&gt;.type=xxx spring.shardingsphere.rules.encrypt.encryptors.&lt;encrypt-algorithm-name&gt;.props.xxx=xxx 读写分离负载均衡算法 # load-balance-algorithm-name 由用户指定,需要和读写分离规则中的 load-balancer-name 属性一致 # type 和 props,请参考读写分离负载均衡内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/load-balance/ spring.shardingsphere.rules.readwrite-splitting.load-balancers.&lt;load-balance-algorithm-name&gt;.type=xxx spring.shardingsphere.rules.readwrite-splitting.load-balancers.&lt;load-balance-algorithm-name&gt;.props.xxx=xxx 影子算法 # shadow-algorithm-name 由用户指定,需要和影子库规则中的 shadow-algorithm-names 属性一致 # type 和 props,请参考影子库内置算法:https://shardingsphere.apache.org/document/current/cn/user-manual/shardingsphere-jdbc/builtin-algorithm/shadow/ spring.shardingsphere.rules.shadow.shadow-algorithms.&lt;shadow-algorithm-name&gt;.type=xxx spring.shardingsphere.rules.shadow.shadow-algorithms.&lt;shadow-algorithm-name&gt;.props.xxx=xxx 高可用 # discovery-type-name 由用户指定,需要和数据库发现规则中的 discovery-type-name 属性一致 spring.shardingsphere.rules.database-discovery.discovery-types.&lt;discovery-type-name&gt;.type=xxx spring.shardingsphere.rules.database-discovery.discovery-types.&lt;discovery-type-name&gt;.props.xxx=xxx </description> |
| </item> |
| |
| </channel> |
| </rss> |