tags:

views:

227

answers:

3

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

A: 

You may find some info here

Boris Pavlović
+6  A: 
<bean id="testWithConstructorArg"
        class="com.Test">
        <constructor-arg ref="referencingSomething"/>
</bean>

more: http://www.javalobby.org/java/forums/t18396.html

Simon Groenewolt
Well, that was easy. :)
Allain Lalonde
A: 

<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.

simonlord