1.Pom加入依賴
<!-- spring auto Decrypt jasypt -->
<dependency>
????<groupId>com.github.ulisesbocchio</groupId>
????<artifactId>jasypt-spring-boot-starter</artifactId>
????<version>2.1.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jasypt/jasypt? ?不需要?-->
<!--<dependency>-->
????<!--<groupId>org.jasypt</groupId>-->
????<!--<artifactId>jasypt</artifactId>-->
????<!--<version>1.9.0</version>-->
<!--</dependency>-->
2.在本機(jī)JDK/bin目錄下用命令生成加密密碼(其中password=panther?為?鹽值(key),input=eisinfra?為需要加密的值)
java -cp C:\Users\e662534\.m2\repository\org\jasypt\jasypt\1.9.0\jasypt-1.9.0.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI password=panther algorithm=PBEWithMD5AndDES input=pq97ybdFF&w*1h%3
3.將生成的密碼配置在配置文件application.yml中剿吻,用ENC()包裹密碼
password: ENC(aRzTh8ypM7K2Gs9P7h4dSxSR3671kj4q)
fgHnMUg88MSwpR+ZPB5k/6666/fkNdYJ
4.在項(xiàng)目中配置鹽值畸悬,或者直接在配置文件中配置(jasypt.encryptor.password=panther)
IDEA中配置:
eclipse中在run?configurations中加鹽值