Reputation: 715
In Spring, I'd like to do the following:
<import resource="${resourceFile}" />
However, 'resourceFile' is not evaluated by the import.
The reason why I need it to work is I defined to two different resourceFiles: resources-serviceA.xml resources-serviceB.xml
Each of the above files define different sets of beans. When running ServiceA, I wouldn't need the beans needed just for ServiceB and hence I do not want to create them.
Any pointers on how to accomplish this?
We are using Spring 3.0.
Upvotes: 0
Views: 2205
Reputation: 17774
Spring 3.0 can not evaluate properties inside import
tag, evaluating those was one of the new features of Spring 3.1 (in 2011)
See Spring 3.1 M1: Unified Property Management
So basically you should use the actual version of Spring. Spring 3.1+ also introduced bean profiles, so you can define ServiceA and ServiceB in different profiles.
If you are interested how this problem was solved by users of Spring 3.0 you can look at Import Spring config file based on property in .properties file but keep in mind that Spring 3.0 is 3 years old now, it's suspicious to make changes in the basic bootstrapping configuration of the 3yo project, consider switching to Spring 4.0+.
Upvotes: 1