Spring constructor options?

Some of my classes have finite fields that are populated from the constructor, as well as properties that can be assigned from getters and setters.

If I can do this with spring, what does the springcontext.xml file look like that creates the objects this way?

thanks

+3
source share
2 answers
<bean id="testWithConstructorArg"
        class="com.Test">
        <constructor-arg ref="referencingSomething"/>
</bean>

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

+8
source

<bean id="myBean" class ="com.example.MyClass">
<constructor-arg type="java.lang.String">
<value>hello world</value>
</constructor-arg>
</bean>

then you can usually use regular tterp teter> setter / getter.

+1
source

All Articles