2
votes

We have been using Spring @Value annotation to inject the property values. We have a convention to name the property names to match the java fields they inject. This bring in unnecessary work that each of config bean's java fields needs to be annotated with @Value.

I'm looking for a way to just annotate the java class with new annotation (let's say ConfigBean) and have some post processor read the property names of such beans and inject the property values automatically.

I'm looking for some pointers on how to go about implementing this property injection without @Value annotation.

1
What's the convention for choosing which fields should be injected and which shouldn't?Sotirios Delimanolis
We use config bean "pattern" where all properties of the bean which would have been annotated with "ConfigBean" are meant to be injected. See this blog [1] for more info. [1] petrikainulainen.net/programming/spring-framework/…singularity

1 Answers

2
votes

you might want to take a look at spring boot's ConfigurationProperties annotation.

see this link for an example.