Skip to content

CAFapi/caf-util-spring

Repository files navigation

caf-util-spring

This project provides Spring utility code.

caf-propertysource-spring

This module provides a custom Spring Boot property source that allows for integration of secrets into your application's configuration.

Usage

  1. Add the caf-propertysource-spring dependency to your project:
<dependency>
    <groupId>com.github.cafapi.util.spring</groupId>
    <artifactId>caf-propertysource-spring</artifactId>
    <version>VERSION</version>
</dependency>
  1. Register the CafConfigEnvironmentListener:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class MyApplication {

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(MyApplication.class);
        app.addListeners(new CafConfigEnvironmentListener()); // Register the listener
        app.run(args);
    }
}
  1. In your application.properties or application.yaml, you can now use the secret: prefix to reference secrets:
my.secret.property: ${secret:MY_SECRET_KEY}
my.secret.with.default: ${secret:ANOTHER_SECRET_KEY:defaultValue}

The secrets will be automatically resolved during application startup.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages