求教一个 Java 问题,关于 configuration-processor 配置提示

2022-11-28 23:33:52 +08:00
 lslvxy
com:
  github:
    xxx:
      - name: abc
        binder:
          type: aaa
          prop1: xxx
          prop2: yyy
          prop3: zzz
      - name: bcd
        binder:
          type: bbb
          prop4: ppp
          prop5: ooo
          prop6: iii

自定义的配置如上的结构,每个 binder 都有固定的 type 字段,下面的字段则根据 type 的值配置的,不是固定写死的,我在 ConfigurationProperties 的类里面该怎么定义 POJO ,让 yaml 能识别到并自动提示呢

1222 次点击
所在节点    Java
5 条回复
v2wtf
2022-11-29 00:05:03 +08:00
```
class Binder {
public String type;
public String xxx;
public String yyy;

}

class Item {
public String name;
public Binder binder;
}

class MyProperties {
public List<Item> items;
}
```
lslvxy
2022-11-29 00:34:00 +08:00
@v2wtf 不是这样的,属性名需要根据 type 的值自定义的
chendy
2022-11-29 08:20:17 +08:00
可以考虑这么一个结构,耦合性强了一些,但是处理起来比较方便:
name: '', binder1: {}, binder2: {}, binder3: {}
goalidea
2022-11-29 10:05:42 +08:00
写好 readme.md 比 ide 提示强
zhady009
2022-11-29 12:23:39 +08:00
没生成 additional-spring-configuration-metadata.json 吧

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/898659

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX