Reputation: 11336
I am trying to find if this is possible: I want t have a property file say
`
prop.properties:
classDefA=com.ClassA
classDefB=com.ClassB
classDefC=com.ClassC
classType=classDefA #or may be classType=classDefB ...
application-context.xml :
...
<bean id="beanToUse" class="${classType}" />
...
`
Here if in the prop file, if i did classType=classDefA, i want it to put com.ClassA. One of the reason I am exploring this route is because i only want the class loader to load one of the class based on value in the property file
Upvotes: 0
Views: 467
Reputation: 58094
This should work:
<util:properties id="props" location="application.properties"/>
<bean id="beanToUse" class="#{props['classType']}" />
Upvotes: 0
Reputation: 847
Have you looked into Spring profiles?
http://blog.springsource.com/2011/02/11/spring-framework-3-1-m1-released/
You can define bean definitions with different profile names and specify which profile you want to use at initialization.
Upvotes: 1