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
From stackoverflow
-
You may find some info here
-
<bean id="testWithConstructorArg" class="com.Test"> <constructor-arg ref="referencingSomething"/> </bean>
more: http://www.javalobby.org/java/forums/t18396.html
Allain Lalonde : Well, that was easy. :) -
<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.
0 comments:
Post a Comment