1.pom.xml
<!--java加密包对配置文件中的密码进行加密--> <dependency> <groupId>com.github.ulisesbocchio</groupId> <artifactId>jasypt-spring-boot-starter</artifactId> <version>1.8</version> </dependency>
2.application.properties
jasypt.encryptor.password=123456
3.controller
@Autowired private StringEncryptor stringEncryptor;
@RequestMapping("/testEnc") @ResponseBody public String encryptPwd() { String result = stringEncryptor.encrypt("123456"); return result; }
4.最后将返回的result手动放到password
spring.datasource.password=ENC(u+xLqTbeOVm7MGhc45LEIw==)