Hi all,
I'm migrating my Spring configuration from XML bean definitions to class annotations. It's going well (and I like the result) but there's one issue for which I can't find a satisfying answer which involves bean property values.
Suppose I have the following bean definition:
This is clean and it allows me to change the fromAddress property without rebuilding the entire application. But if MailBuilder is annotated with @Component, how can I inject a simple String property into fromAddress?Code:<bean id="mailBuilder" class="com.xyz.MailBuilder"> <property name="fromAddress" value="admin@xyz.com" /> </bean>
The best I could come up with so far is to create the following bean definition:
and use the @Resource annotation on the MailBuilder's setter. It works, but it seems awfully verbose for just a simple String property. Plus, if I have 2 builders (one for user activation, the other for lost passwords), I also have to "namespace" these properties to distinguish between them.Code:<bean id="fromAddress" class="java.lang.String"> <constructor-arg index="0" value="admin@xyz.com" /> </bean>
Any ideas on how to improve this?
Thanks a bunch!


Reply With Quote
