springboot项目利用ShardingSphere实现数据库字段加解密
使用默认的加解密方式
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
<version>4.0.0</version>
</dependency>
spring:
shardingsphere:
datasource:
name: master
master:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.20.181:3060/collateral?useSSL=false&allowPublicKeyRetrieval=true&characterEncoding=utf8
username: 数据库用户名
password: 数据库密码
encrypt:
encryptors:
encryptor_aes:
type: aes
props:
aes.key.value: abcdef#ghij#klmn
tables:
t_collateral_record:
columns:
project_name:
cipherColumn: project_name
encryptor: encryptor_aes
project_no:
cipherColumn: project_no
encryptor: encryptor_aes
props:
sql:
show: false
query:
with:
cipher:
column: true
使用自定义的加解密方式
<