Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
d0781c5e
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d0781c5e
编写于
5月 27, 2020
作者:
Z
zhyee
提交者:
GitHub
5月 27, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add springboot examples for shadow (#5808)
上级
cdb2f2a4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
130 addition
and
12 deletion
+130
-12
examples/example-core/example-spring-jpa/src/main/java/org/apache/shardingsphere/example/core/jpa/entity/ShadowUserEntity.java
...rdingsphere/example/core/jpa/entity/ShadowUserEntity.java
+1
-12
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-spring-boot-example/src/main/resources/application-encrypt-shadow-databases.properties
...resources/application-encrypt-shadow-databases.properties
+43
-0
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-spring-boot-example/src/main/resources/application-master-slave-shadow-databases.properties
...rces/application-master-slave-shadow-databases.properties
+39
-0
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-spring-boot-example/src/main/resources/application-sharding-shadow-databases.properties
...esources/application-sharding-shadow-databases.properties
+44
-0
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-spring-boot-example/src/main/resources/application.properties
...ng-boot-example/src/main/resources/application.properties
+3
-0
未找到文件。
examples/example-core/example-spring-jpa/src/main/java/org/apache/shardingsphere/example/core/jpa/entity/ShadowUserEntity.java
浏览文件 @
d0781c5e
...
...
@@ -25,7 +25,7 @@ import javax.persistence.Id;
import
javax.persistence.Table
;
@Entity
@Table
(
name
=
"t_user"
)
@Table
(
name
=
"t_
shadow_
user"
)
public
final
class
ShadowUserEntity
extends
ShadowUser
{
private
static
final
long
serialVersionUID
=
-
3708998745561667721L
;
...
...
@@ -43,23 +43,12 @@ public final class ShadowUserEntity extends ShadowUser {
return
super
.
getUserName
();
}
@Column
(
name
=
"user_name_plain"
)
@Override
public
String
getUserNamePlain
()
{
return
super
.
getUserNamePlain
();
}
@Column
(
name
=
"pwd"
)
@Override
public
String
getPwd
()
{
return
super
.
getPwd
();
}
@Column
(
name
=
"assisted_query_pwd"
)
@Override
public
String
getAssistedQueryPwd
()
{
return
super
.
getAssistedQueryPwd
();
}
@Column
(
name
=
"shadow"
)
@Override
...
...
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-spring-boot-example/src/main/resources/application-encrypt-shadow-databases.properties
0 → 100644
浏览文件 @
d0781c5e
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
spring.shardingsphere.datasource.names
=
ds,shadow_ds
spring.shardingsphere.datasource.common.type
=
com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.common.driver-class-name
=
com.mysql.jdbc.Driver
spring.shardingsphere.datasource.common.username
=
root
spring.shardingsphere.datasource.common.password
=
spring.shardingsphere.datasource.ds.jdbc-url
=
jdbc:mysql://localhost:3306/demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.shadow_ds.jdbc-url
=
jdbc:mysql://localhost:3306/shadow_demo_ds?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.rules.shadow.column
=
shadow
spring.shardingsphere.rules.shadow.shadow-mappings.ds
=
shadow_ds
spring.shardingsphere.rules.encrypt.encryptors.name_encryptor.type
=
aes
spring.shardingsphere.rules.encrypt.encryptors.name_encryptor.props.aes.key.value
=
123456
spring.shardingsphere.rules.encrypt.encryptors.pwd_encryptor.type
=
assistedTest
spring.shardingsphere.rules.encrypt.tables.t_shadow_user.columns.user_name.plainColumn
=
user_name_plain
spring.shardingsphere.rules.encrypt.tables.t_shadow_user.columns.user_name.cipherColumn
=
user_name
spring.shardingsphere.rules.encrypt.tables.t_shadow_user.columns.user_name.encryptor
=
name_encryptor
spring.shardingsphere.rules.encrypt.tables.t_shadow_user.columns.pwd.cipherColumn
=
pwd
spring.shardingsphere.rules.encrypt.tables.t_shadow_user.columns.pwd.assistedQueryColumn
=
assisted_query_pwd
spring.shardingsphere.rules.encrypt.tables.t_shadow_user.columns.pwd.encryptor
=
pwd_encryptor
spring.shardingsphere.props.query.with.cipher.comlum
=
true
spring.shardingsphere.props.sql.show
=
true
\ No newline at end of file
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-spring-boot-example/src/main/resources/application-master-slave-shadow-databases.properties
0 → 100644
浏览文件 @
d0781c5e
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
spring.shardingsphere.datasource.names
=
ds_master,ds_slave,shadow_ds_master,shadow_ds_slave
spring.shardingsphere.datasource.common.type
=
com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.common.driver-class-name
=
com.mysql.jdbc.Driver
spring.shardingsphere.datasource.common.username
=
root
spring.shardingsphere.datasource.common.password
=
spring.shardingsphere.datasource.ds_master.jdbc-url
=
jdbc:mysql://localhost:3306/demo_ds_master?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.shadow_ds_master.jdbc-url
=
jdbc:mysql://localhost:3306/demo_shadow_ds_master?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.ds_slave.jdbc-url
=
jdbc:mysql://localhost:3306/demo_ds_slave?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.shadow_ds_slave.jdbc-url
=
jdbc:mysql://localhost:3306/demo_shadow_ds_slave?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.rules.shadow.column
=
shadow
spring.shardingsphere.rules.shadow.shadow-mappings.ds_master
=
shadow_ds_master
spring.shardingsphere.rules.shadow.shadow-mappings.ds_slave
=
shadow_ds_slave
spring.shardingsphere.rules.master-slave.data-sources.ds_ms.master-data-source-name
=
ds_master
spring.shardingsphere.rules.master-slave.data-sources.ds_ms.slave-data-source-names
=
ds_slave
spring.shardingsphere.rules.master-slave.data-sources.ds_ms.load-balance-algorithm-type
=
round_robin
\ No newline at end of file
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-spring-boot-example/src/main/resources/application-sharding-shadow-databases.properties
0 → 100644
浏览文件 @
d0781c5e
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
spring.shardingsphere.datasource.names
=
ds_0,ds_1,shadow_ds_0,shadow_ds_1
spring.shardingsphere.datasource.common.type
=
com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.common.driver-class-name
=
com.mysql.jdbc.Driver
spring.shardingsphere.datasource.common.username
=
root
spring.shardingsphere.datasource.common.password
=
spring.shardingsphere.datasource.ds_0.jdbc-url
=
jdbc:mysql://localhost:3306/demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.ds_1.jdbc-url
=
jdbc:mysql://localhost:3306/demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.shadow_ds_0.jdbc-url
=
jdbc:mysql://localhost:3306/shadow_demo_ds_0?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.datasource.shadow_ds_1.jdbc-url
=
jdbc:mysql://localhost:3306/shadow_demo_ds_1?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=UTF-8
spring.shardingsphere.rules.shadow.column
=
shadow
spring.shardingsphere.rules.shadow.shadow-mappings.ds_0
=
shadow_ds_0
spring.shardingsphere.rules.shadow.shadow-mappings.ds_1
=
shadow_ds_1
spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-column
=
user_id
spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding_algorithm.type
=
INLINE
spring.shardingsphere.rules.sharding.default-database-strategy.standard.sharding-algorithm.props.algorithm.expression
=
ds_$->{user_id % 2}
spring.shardingsphere.rules.sharding.tables.t_shadow_user.actual-data-nodes
=
ds_$->{0..1}.t_user
spring.shardingsphere.rules.sharding.tables.t_shadow_user.key-generator.column
=
order_id
spring.shardingsphere.rules.sharding.tables.t_shadow_user.key-generator.type
=
SNOWFLAKE
spring.shardingsphere.rules.sharding.tables.t_shadow_user.key-generator.props.worker.id
=
123
examples/shardingsphere-jdbc-example/other-feature-example/shadow-example/shadow-spring-boot-example/src/main/resources/application.properties
浏览文件 @
d0781c5e
...
...
@@ -20,3 +20,6 @@ spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.jpa.properties.hibernate.show_sql
=
true
spring.profiles.active
=
shadow-databases
#spring.profiles.active=master-slave-shadow-databases
#spring.profiles.active=sharding-shadow-databases
#spring.profiles.active=encrypt-shadow-databases
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录