External properties @configurationProperties style prefix for proprties with not predefined structure

85 views Asked by At

I have some properties, where some initial part is same and remaining is different for all properties. can have 1 dot (.) 2,3 or more. I can't use @ConfigurationProperties to loca these with prefix ="com.some.props" because remaining properties are different

com:
 some:
  props:
     prop1:
       someProp: value
     prop2:
        anotherProp:
         innerprop: value2

So I created a custom props class and used @Value but I have to write full property path for wach variable. Is there a way I can apply a prefix for all @Value in a class

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

There are 0 answers