Reputation: 93348
Some of my classes have final fields that are populated from the constructor as well as properties that can be assigned from getters and setters.
If I can do this using spring, what does the springcontext.xml file look like that creates objects in this way?
Thank you
Upvotes: 4
Views: 685
Reputation: 4367
<bean id="myBean" class ="com.example.MyClass">
<constructor-arg type="java.lang.String">
<value>hello world</value>
</constructor-arg>
</bean>
then you can have the normal setter/getter based <paramater name="blah" value="whatever"/>
as usual.
Upvotes: 1
Reputation: 10665
<bean id="testWithConstructorArg"
class="com.Test">
<constructor-arg ref="referencingSomething"/>
</bean>
more: http://www.javalobby.org/java/forums/t18396.html
Upvotes: 8