Skip to content

Spring's @DynamicPropertySource registering config too late for bootstrapping Testcontainer #8

@vaughan-naidoo

Description

@vaughan-naidoo

I am setting Spring config by running a HashiCorp Vault container for local development using Testcontainers. Before DynamicPropertySource properties are set, Spring has already configured Vault using defaults and attempts to connect to the Vault instance using these defaults (e.g. Spring configures port 8200 instead of the first mapped port of the Vault Testcontainer).

The result is a connection refused error "Connect to http://localhost:8200 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused: no further information". This is due to the config being incorrect and the Vault Testcontainer not running at that time.

I have a configuration class annotated @TestConfiguration and run the application main with this config as documented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions