运行背景
apollo版本:1.2.0
实现方式如下:
1、拉取github中1.2.0版本的代码
2、增加jasypt-spring-boot依赖【版本APOLLO已经控制,无需指定版本】
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot</artifactId>
</dependency>
3、修改admin、config、portal的启动类增加@EnableEncryptableProperties 注解
4、在~/.bash_profile增加环境变量用于控制使用的profile apollo_profile=github export apollo_profile
5、使用jasypt-1.9.2.jar 加密原始密码后修改响应配置文件后重启。
密码加密命令
jasypt加密
java -cp jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="123456" password="mysalt" algorithm=PBEWithMD5AndDES
input:密码
password:盐
algorithm:加密方式
配置加密
需要加密的密码改用:ENC(加密命令执行结果)