I have a bean Parent with just one property attr.
class Parent
{
String attr;
public void doStuff(){
//stuff
}
public String getAttr() {
return attr;
}
public void setAttr(String attr) {
this.attr=attr;
}
}
I have three beans that extend this Parent bean. My spring.xml looks like this-
<bean id="parent" class="Parent"/>
<bean id="child1" parent="parent">
<property name="attr" value="Sample value 1"/>
</bean>
<bean id="child2" parent="parent">
<property name="attr" value="Sample value 2"/>
</bean>
<bean id="child3" parent="parent">
<property name="attr" value="Sample value 3"/>
</bean>
I want to do the same thing using annotations. Problem is that I have to do this storefront and all the beans in my controller are declared as -
@Resource
@Qualifier("child1")
Parent child1;
Is there a way I can add the property to the child beans using annotations or any other approach in controller i.e. without using spring.xml?
Is there a way of doing this using the @Value annotation. Problem is that I don't have a static value that comes from a property file. I have 3 different value for 3 different beans.