The Spring team has published a fresh look at secret management for Java applications, ten years after its first guide to using HashiCorp Vault with Spring. In a post on the Spring blog dated December 4, 2026, Spring Vault lead Mark Paluch explains how the ManagedSecret API, introduced in Spring Vault 4.1, aims to close a long-standing gap between rotating credentials in Vault and the database connection pools that actually use them. The post is the first of two parts, with the second planned to cover managed certificates.
From key value store to rotation engine
According to the post, Vault began as a simple store for credentials and has grown into a system that can issue and rotate secrets for databases and other services. Spring Vault already renews leases while an application runs and revokes them on a normal shutdown, so that credentials expire if the app crashes or loses its connection to Vault. Paluch distinguishes two rotation models. With dynamic roles, Vault creates a new login and renews its lease until it expires. With static roles, Vault changes the password of an existing user, and because that is not tied to a lease, the application has to poll or refresh on its own.
The connection pool problem
The harder part, the post argues, is getting new credentials into a connection pool that holds long-lived database connections. Few JDBC pools can change their username and password at runtime, with HikariCP named as one of the exceptions. In a typical setup, a secret declaration, a listener and the pool are wired together loosely, which Paluch describes as error prone. He identifies three gaps: no uniform approach to rotation, limited support in drivers and pools, and no coordination between the pieces.
How ManagedSecret works
ManagedSecret ties the declaration of a secret to the code that consumes it in a single place, typically a Spring bean method. Spring Vault calls that consumer whenever Vault creates or rotates the secret, and an optional error handler can be added. A helper type for username and password pairs, designed for Vault’s dynamic database engines, lets developers apply new credentials straight to a HikariCP data source and gradually evict old connections. The Spring Vault reference documentation for version 4.1.2 shows the same pattern and notes that it builds on the existing SecretLeaseContainer, which fires events when leases are renewed, rotated, expire or fail.
Startup order and pitfalls
The post warns that ordering matters in Spring Cloud Vault applications. Secrets imported through Spring configuration data are fetched first, while ManagedSecret beans register later, so they receive rotation and error notifications rather than the initial secret. Spring Vault does not cache secrets. The documentation similarly cautions that credentials are not available until the lease container has started, so components that need them during early initialisation may run too soon.
Availability
ManagedSecret has been available since Spring Vault 4.1, which reached general availability on June 10, 2026, together with a fluent VaultClient API, ManagedCertificate and a CertificateContainer for certificate rotation. The new post mainly brings the feature and revised rotation guidance to a wider audience, and it points readers to a full example in the Spring Cloud Vault samples repository.
Sources:
- Spring Blog (Managed Secrets revisited)
- Spring Vault reference docs
- Spring Blog (Spring Vault 4.1 GA)

