Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add functionality to Spring Cloud Bootstrap

Tags:

spring-cloud

I want to add some lookup before the Spring context is loaded, which is ideally on the bootstrap phase of Spring Cloud (When it lookup for Configuration Server, Cloud connectors etc). How can I make my code to be executed on that phase ?

What I want to do is query Vault to get all my databases secrets and api keys and set the properties, I know I can encrypt with Spring Cloud Config, but I liked the strong box of Vault. (The integration with Vault part I can handle)

like image 387
Joao Evangelista Avatar asked Nov 29 '15 01:11

Joao Evangelista


Video Answer


1 Answers

As I saw in the code of Spring Cloud Config, the bootstrap configuration is auto-configured by using the class org.springframework.cloud.bootstrap.BootstrapConfiguration on the resources/META-INF/spring.factories file, the same which you can use to register new auto configuration classes for Spring Boot, as reference you can refer to the file on the project here. This will make your configuration be started and registered before the "normal" application context.

like image 94
Joao Evangelista Avatar answered Dec 17 '22 12:12

Joao Evangelista