Java 未预定义结构的属性的外部属性@configurationProperties样式前缀

Java 未预定义结构的属性的外部属性@configurationProperties样式前缀,java,spring-boot,configurationproperties,Java,Spring Boot,Configurationproperties,我有一些属性,其中一些初始部分是相同的,其余部分对于所有属性都是不同的。 可以有1个点(.)2,3或更多。 我无法使用@ConfigurationProperties将它们与prefix=“com.some.props”一起定位,因为其余属性不同 com: some: props: prop1: someProp: value prop2: anotherProp: innerprop: value2 所以我创建了一个定

我有一些属性,其中一些初始部分是相同的,其余部分对于所有属性都是不同的。 可以有1个点(.)2,3或更多。 我无法使用
@ConfigurationProperties
将它们与
prefix=“com.some.props”
一起定位,因为其余属性不同

com:
 some:
  props:
     prop1:
       someProp: value
     prop2:
        anotherProp:
         innerprop: value2
所以我创建了一个定制的props类并使用了
@Value
,但我必须为wach变量编写完整的属性路径。 有没有一种方法可以为类中的所有
@Value
应用前缀

@Component (prefix="com.some.props") //Not a valid code, but want something of this sort.  
class props {
   @Values ("${prop1.someprop}")
   String someprop;
   @Values ("${prop2.anotherProp.innerProp}")
   String somethingElse;
}

您是否尝试过使用
公共静态类Prop1Properties
?我不想为一个属性创建类。只想有一个属性类和所有的属性在其中填充。具体来说,为什么?嵌套属性的嵌套类是Spring Boot本身处理这些事情的方式。正如我前面提到的,所有属性都具有不同的结构。因此,我要么重命名属性(其迁移项目),要么在我的ConfigProperties类中创建太多的内部类。。。。。我知道这是春天的标准方式…正如你推荐的。。。但我想问,是否有什么东西可以达到我的要求……)