未验证 提交 d0781c5e 编写于 作者: Z zhyee 提交者: GitHub

add springboot examples for shadow (#5808)

上级 cdb2f2a4
......@@ -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
......
#
# 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
#
# 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
#
# 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
......@@ -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.
先完成此消息的编辑!
想要评论请 注册