Skip to content

Secrets manager does not work as expected with @ConfigurationProperties("prefix") #1205

@hasyimibhar

Description

@hasyimibhar

Type: Bug

Component: Secrets Manager

Describe the bug
Spring Cloud version: 3.1.1

Secrets manager does not work as expected with @ConfigurationProperties("prefix"). Given the following secret:

{
  "EXAMPLE_FOO": "bar"
}

And the following ConfigurationProperties:

@Configuration
@ConfigurationProperties("example")
@Data
public class ExampleProperties {
  private String foo;
}

I expect foo to resolve to bar, but it resolves to null instead.

Without specifying prefix, the following works:

@Configuration
@ConfigurationProperties()
@Data
public class ExampleProperties {
  private String exampleFoo;
}

exampleFoo now resolves to bar.

It is also possible to make it work by adding the following to application.properties:

example.foo=${EXAMPLE_FOO}

Using ?prefix=example. and the following secrets also works:

{
  "FOO": "bar"
}

Sample
N/A. The description above should be enough.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions