This is my spring configuration file :
<bean id="controller" class="com.sample.controller.Controller">
<property name="message" value="Controller1"/>
</bean>
<bean id="controller2" class="com.sample.controller.Controller2">
<property name="message" value="#{controller.message}"/>
</bean>
And the code :
ApplicationContext context =
new ClassPathXmlApplicationContext("beans.xml");
Controller obj = (Controller) context.getBean("controller");
System.out.println(obj.getMessage());
obj.message = "Controller1 changed!";
Controller2 obj2 = (Controller2) context.getBean("controller2");
System.out.println(obj2.getMessage());
I wanted the output to be :
Controller1
Controller1 changed!
but it is
Controller1
Controller1
Is there a simpler way to get the updated value other than injecting Controller into Controller1?
Thank you.