Add dynamic properties into Spring using annotations
I am working on command line application and I wanted to pass parameters from command line (read using Commons CLI) to member variables using annotation @Value.
Put your properties into standard Java Properties
Do not pass parameter to AnnotationConfigApplicationContext constructor, but register your configuration manually
Add your properties wrapped by PropertiesPropertySource into ConfigurableEnvironment
Create bean of class PropertySourcesPlaceholderConfigurer (This is crucial!!!). Without this step it was possible to lookup my properties using env.resolvePlaceholder(…) but not using annotation @Value.