【问题标题】:spring boot expand configuration properties metadata json "hints" for Map not workSpring Boot扩展配置属性元数据json“提示”地图不起作用
【发布时间】:2019-08-05 00:44:58
【问题描述】:

我想在我的项目中扩展配置元数据,就像the documentation 中提到的那样。

通常,我可以使用spring-boot-configuration-processor 依赖项来生成我自己的元数据。但在这种情况下,我在属性中使用了Map<String, Foo> 属性,并且我希望 IDE 在使用这些属性时显示代码提示。

让我给你看代码。

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;
}

附加-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"
    }]
  }]
}

这是我的 IDE 的图像,没有显示任何提示:

我有什么可以改变的吗?

【问题讨论】:

  • 我发现了问题。在我的代码中,我在 FooProperties 上注释了 @Import@Autowird。当我删除这些注释并使用“spring-boot-configuration-processor”依赖项时,它可以工作。所以,这种情况可以正常工作。

标签: java spring spring-boot


【解决方案1】:

我发现了问题。

在我的代码中,我在 FooProperties 上注释了 @Import 和 @Autowird。 当我删除这些注释并使用“spring-boot-configuration-processor”依赖项时,它可以工作。

所以,这种情况可以正常工作。

【讨论】:

    猜你喜欢
    • 2018-05-18
    • 1970-01-01
    • 1970-01-01
    • 2016-12-02
    • 1970-01-01
    • 2021-08-30
    • 2017-10-08
    • 1970-01-01
    • 2018-12-18
    相关资源
    最近更新 更多