Hey,
This trouble is related with the java-based configuration model for Spring.
I'm having a lots of problems trying to programmatically import configuration classes from one external @Configuration class.
The situation is as follows:
- I have on class annotated as @Configuration that reads one properties file with the corresponding @PropertySource annotation and access to the properties in that file by using the Environment
- I have also some other @Configuration classes definedCode:@Configuration @PorpertySource("........") public class ConfigurationBig(){ @Autowired private Environment env; .... }
I know that in order to do the import I should add the annotation @Import({ConfigurationOne.class,ConfigurationTwo.c lass,ConfigurationThree.class}) but the problem is...What if I don't know now and only in Runtime the number of configuration files (and also the name) that should be imported? I want the user to be able to state in the property file (lets say property "configurationClases") which classes he wants to be imported (by stating "configurationClases=ConfigurationOne,Configuratio nTwo,ConfigurationThree").Code:@Configuration public class ConfigurationOne(){ .... } @Configuration public class ConfigurationTwo(){ .... } @Configuration public class ConfigurationThree(){ .... }
Any ideas so far?
Thank you in advance !
Shagrash


Reply With Quote