spring-projects / spring-vault

Provides familiar Spring abstractions for HashiCorp Vault
https://spring.io/projects/spring-vault
Apache License 2.0
283 stars 186 forks source link

Delay `PropertySource` lookup for `VaultPropertySourceRegistrar` #776

Closed mp911de closed 1 year ago

mp911de commented 1 year ago

VaultPropertySourceRegistrar performs an early bean lookup via beanFactory.getBeansOfType(…) to obtain property sources. While this lookup allows for early initialization of components, it triggers in case of Spring Boot the initialization of VaultAutoConfiguration too early which fails with constructor resolution.

We can delay the initialization but that comes at the cost of vault property sources being activated after running the bean postprocessor.

This issue was originally reported via https://github.com/spring-cloud/spring-cloud-vault/issues/642

mp911de commented 1 year ago

Delaying the initialization causes the annotation to miss the point to contribute configuration data early on during bean configuration. We recommend using @VaultPropertySource in combination with AbstractVaultConfiguration to provide the required infrastructure separately from potential auto-configuration.