I like constructor-based injection, as it allows me to enter final input fields. I also like nesting with annotation as it simplifies my context.xml . I can mark my @Autowired constructor, and everything works fine if I don't have two parameters of the same type. For example, I have a class:
@Component public class SomeClass { @Autowired(required=true) public SomeClass(OtherClass bean1, OtherClass bean2) { β¦ } }
and application context with:
<bean id="bean1" class="OtherClass" /> <bean id="bean2" class="OtherClass" />
There should be a way to specify the bean identifier in the constructor of the SomeClass class, but I cannot find it in the documentation. Is it possible, or am I dreaming of a solution that does not yet exist?
java spring
Guillaume Jan 28 '10 at 10:06
source share