I have configuration with
<code>a-configuration-group
prop1: some-hyphen-val1
prop2: some-hyphen-val2
.
.
propn: some-hyphen-valn
</code>
<code>a-configuration-group
prop1: some-hyphen-val1
prop2: some-hyphen-val2
.
.
propn: some-hyphen-valn
</code>
a-configuration-group
prop1: some-hyphen-val1
prop2: some-hyphen-val2
.
.
propn: some-hyphen-valn
There are various classes using the configuration so:
<code>SomeClass {
@Value("${a-configuration-group.some-hyphen-val1}")
private String someHyphenVal1;
@Value("${a-configuration-group.some-hyphen-val2}")
private String someHyphenVal1;
}
</code>
<code>SomeClass {
@Value("${a-configuration-group.some-hyphen-val1}")
private String someHyphenVal1;
@Value("${a-configuration-group.some-hyphen-val2}")
private String someHyphenVal1;
}
</code>
SomeClass {
@Value("${a-configuration-group.some-hyphen-val1}")
private String someHyphenVal1;
@Value("${a-configuration-group.some-hyphen-val2}")
private String someHyphenVal1;
}
I would like to:
- get rid of the recurring
a-configuration-group.
- Not change the java variable names to non-standard naming e.g.
String some-hyphen-val1;
- Not change the configuration property names since they are already used across the code in classes such as
SomeClass
AND in other configuration files which override mine. These changes will require heavy unit testing across various projects and environments.
I know about the @ConfigurationProperties as suggested here but it will conflict with 2 or 3 above.
Is there a way to add an annotation like @ConfigurationProperties
but e.g. keep the @Value
annotation in SomeClass
as to not change variable names?