I am learning spring framework and have a very basic question. I tried to find the answer, but couldn't find it, so bear with me. I have seen the following kind of wiring(it that is what it is called) in spring.
public class A {
private B b;
public A(B b) {
this.b = b;
}
public B getB() {
return b;
}
public void setB(B b) {
this.b = b;
}
}
public class B {
private String foo;
public String getFoo() {
return foo;
}
public void setFoo(String foo) {
this.foo = foo;
}
}
So I understand that this autowiring is done using constructor injection. Then in the context.xml I have the following
<bean id="a" class="A" autowire="constructor">
</bean>
<bean id="b" class="B" >
<property name="foo" value="foo1" />
</bean>
(I am learning the configuration using annotation rather than context.xml, but using it here since it seems to provide a more clear picture). So my question is, since a bean, by definition, should have only no-args constructors and getters and setters, doesn't doing a constructor injection, disqualify it from being a bean? What obvious thing am I missing here?