Jasypt 与 Spring Boot 的集成
Jasypt 对 Spring Boot 3.5+ 的集成
要求: Java 17+ 和 Spring Boot 3.5+
Jasypt Spring Boot 为 Spring Boot 应用中的属性源提供加密支持。
在项目中集成 jasypt-spring-boot 有 3 种方式:
@SpringBootApplication 或 @EnableAutoConfiguration,只需将启动器 jar jasypt-spring-boot-starter 添加到类路径中,即可在整个 Spring 环境中启用可加密属性jasypt-spring-boot 添加到类路径中,并在主配置类上添加 @EnableEncryptableProperties,以在整个 Spring 环境中启用可加密属性jasypt-spring-boot 添加到类路径中,并使用 @EncryptablePropertySource 声明各个可加密属性源使用以下 3 种方法之一(上面已简要说明):
@SpringBootApplication 或 @EnableAutoConfiguration,只需将 starter jar 依赖添加到项目中,即可在整个 Spring 环境中启用可加密属性(这意味着任何系统属性、环境属性、命令行参数、application.properties、application-*.properties、yaml 属性以及任何其他属性源都可以包含加密属性): <dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot-starter</artifactId>
<version>4.0.4</version>
</dependency>
```
2. 如果你不使用 `@SpringBootApplication` 或 `@EnableAutoConfiguration` 自动配置注解,则将以下依赖添加到项目中:
```xml
<dependency>
<groupId>com.github.ulisesbocchio</groupId>
<artifactId>jasypt-spring-boot</artifactId>
<version>4.0.4</version>
</dependency>
```
然后,将 `@EnableEncryptableProperties` 添加到你的配置类中。例如:
```java
@Configuration
@EnableEncryptableProperties
public class MyAp
```暂无开放 Issues,或尚未同步最近议题。