Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring Config: Using @ConfigurationProperties to inject maps does not work #19366

Closed
Sgitario opened this issue Aug 12, 2021 · 2 comments · Fixed by #19570
Closed

Spring Config: Using @ConfigurationProperties to inject maps does not work #19366

Sgitario opened this issue Aug 12, 2021 · 2 comments · Fixed by #19570
Labels
area/spring Issues relating to the Spring integration kind/bug Something isn't working
Milestone

Comments

@Sgitario
Copy link
Contributor

Describe the bug

Spring users can bind maps like this:

@ConfigurationProperties("maps")
public class MapWiringProperties {

    // Cover injection of maps of integers and strings;
    public Map<Integer, String> integers;

    // Cover injection of maps of string and classes
    public Map<String, Person> persons;

    public static class Person {
        public String name;
        public int age;

        @Override
        public String toString() {
            return String.format("person[%s:%s]", name, age);
        }
    }
}

With application.properties:

maps.integers.1=Value 1
maps.integers.2=Value 2

maps.persons.character1.name=Sarah
maps.persons.character1.age=19
maps.persons.character2.name=Terminator
maps.persons.character2.age=999

If we try to use the same using the spring properties Quarkus extension, it throws the following exception:

Caused by: java.lang.IllegalArgumentException: SRCFG00013: No Converter registered for interface java.util.Map

Expected behavior

Not sure if this is very complex to mimic in the Quarkus extension (we should generate the equivalent object using the @ConfigMapping annotation.
However, if this is too complex to support, we should document the current limitations in the Spring properties guide.

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

No response

Output of java -version

No response

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@Sgitario Sgitario added the kind/bug Something isn't working label Aug 12, 2021
@quarkus-bot quarkus-bot bot added the area/spring Issues relating to the Spring integration label Aug 12, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Aug 12, 2021

/cc @geoand

@geoand
Copy link
Contributor

geoand commented Aug 12, 2021

This is a known limitation of @ConfigProperties. We should just print a more relevant error message.

I'll do that when I get back from PTO

geoand added a commit to geoand/quarkus that referenced this issue Aug 23, 2021
gsmet added a commit that referenced this issue Aug 24, 2021
Provide clear build-time error message when using Map in @ConfigProperties
@quarkus-bot quarkus-bot bot added this to the 2.3 - main milestone Aug 24, 2021
@gsmet gsmet modified the milestones: 2.3 - main, 2.2.0.Final Aug 24, 2021
gsmet pushed a commit to gsmet/quarkus that referenced this issue Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/spring Issues relating to the Spring integration kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants