Skip to content

03 配置文件加密说明

liuweijw edited this page Mar 14, 2018 · 1 revision

1、单独模块的进入工程单独修改

2、初始化数据

3、公共配置

spring:
  application:
    name: system-config-server
  profiles:
    active: dev
  cloud:
    config: 
      server:
        git:
          uri: https://github.com/liuweijw/fw-cloud-framework-config.git # 配置git仓库的地址

3、配置加密,采用jasypt解决方案

  • 添加Maven依赖
<dependency>
    <groupId>com.github.ulisesbocchio</groupId>
    <artifactId>jasypt-spring-boot-starter</artifactId>
    <version>1.16</version>
</dependency>
  • 配置
jasypt:
  encryptor:
    password: liuweijw #根密码
  • 调用JAVA API 生成密文
@Autowired private StringEncryptor stringEncryptor;
stringEncryptor.encrypt("liuweijw") // 得到密文
  • 配置文件中使用密文
spring:
  datasource:
    password: ENC(密文)
Clone this wiki locally