springboot 的yaml配置文件加密

一、采用yaml 插件加密

使用Jasypt对Spring Boot的YAML配置文件进行加密是一种保护敏感信息(如数据库密码、API密钥等)的有效方法。Jasypt(Java Simplified Encryption)是一个Java加密工具库,它提供了一种简单的方式来实现文本的加密和解密。下面是如何在Spring Boot项目中集成Jasypt并加密YAML配置的步骤:

添加依赖

首先,在你的pom.xml或build.gradle文件中添加Jasypt Spring Boot Starter的依赖。

        <!--        jasypt加密依赖-->
        <dependency>
            <groupId>com.github.ulisesbocchio</groupId>
            <artifactId>jasypt-spring-boot-starter</artifactId>
            <version>3.0.5</version>
        </dependency>
implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.5' // 请检查最新版本

创建启动类

我们需要在启动类上加上一个@EnableEncryptableProperties开启jasypt配置

@SpringBootApplication
@EnableEncryptableProperties
public class FileServerApplication {
   
   

    public static 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值