0

I want to expand configuration metadata in my project just as mentioned in the documentation.

Usually, I can use the spring-boot-configuration-processor dependency to generate my own metadata. But in this case, I'm using Map<String, Foo> properties in my properties, and I want the IDE to show code hints when using these propertie.

Let me show you the code.

FooProperties

@ConfigurationProperteis("server.worker")
public class FooProperties {
    private int workerCount;
    private int subWorkerCount;
    private int limit;
    @NestedConfigurationProperty
    private Map<String, BooProperties> group = new HashMap<>();
    //getter and setter
}

BooProperties

public class BooProperties{
    private int workerCount;
}

additional-spring-configuration-metadata.json

{
  "properties":[{
    "name": "server.worker.group",
    "type":"java.util.Map<java.lang.String,com.FooProperties>",
    "description": ".....",
    "sourceType":"com.FooProperties"
  }],
  "hints":[{
    "name":"server.worker.group.keys",
    "providers":[{
      "name":"any"
    }]
  }, {
    "name":"server.worker.group.values",
    "providers" : [{
      "name":"class-reference"
    }]
  }]
}

And this is an image of my IDE, not showing any hints:

Image of IDE

Is there anything I can change to make this work?

g00glen00b
  • 41,995
  • 13
  • 95
  • 133
ly0932
  • 39
  • 1
  • 5
  • I found the problem. In my code, I annotated `@Import` and `@Autowird` on FooProperties. When I remove those annotations and use the 'spring-boot-configuration-processor' dependency, It works. So, that case can work fine. – ly0932 Mar 14 '19 at 11:40

1 Answers1

0

I found the problem.

In my code, I annotated @Import and @Autowird on FooProperties. When I remove those annotations and use the 'spring-boot-configuration-processor' dependency, It works.

So, that case can work fine.

ly0932
  • 39
  • 1
  • 5