admin管理员组文章数量:1639831
1.pom.xml 文件中引入
<!-- https://mvnrepository/artifact/com.github.ulisesbocchio/jasypt-spring-boot-starter -->
<!-- 整合jasypt对数据库密码加密 -->
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>1.16</version>
</dependency>
2.在windows下命令生成加密密文
java -cp G:\maven\repository\org\jasypt\jasypt\1.9.2\jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="you4new!" password=saltnewfor algorithm=PBEWithMD5AndDES
参数说明:
input =数据库链接密码
password=加密字段,随意设置
algorithm= 算法
执行后有以下输出
----ENVIRONMENT-----------------
Runtime: Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 25.131-b11
----ARGUMENTS-------------------
algorithm: PBEWithMD5AndDES
input: you4new!
password: saltnewfor
----OUTPUT----------------------
UK61bS+W/BskHl0N0ViAQcrPAmZLZZwO
3.在spring boot 项目的配置文件中加入以下内容
#spring.datasource.url=jdbc:mysql://localhost:3306/Solrsearch
#spring.datasource.username=root
#jasypt.encryptor.password=${password}
#jasypt.encryptor.password=aidan123456
#spring.datasource.password=ENC(UK61bS+W/BskHl0N0ViAQcrPAmZLZZwO)
#spring.datasource.driver-class-name=com.mysql.jdbc.Driver
https://www.ricston/blog/encrypting-properties-in-spring-boot-with-jasypt-spring-boot/
https://www.ricston/blog/encrypting-properties-in-spring-boot-with-jasypt-spring-boot/
http://wwwblogs/zz0412/p/jasypt-001.html
https://github/ulisesbocchio/jasypt-spring-boot
版权声明:本文标题:spring boot 配置数据库加密 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1729296611a1194800.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论