Spring如何注入引用的bean之间有什么区别
MyClass.java
public class MyClass {
@Inject
@Named("myNiceBean")
private MyBean bean;
public MyBean getBean() { return bean; }
public void setBean(MyBean bean) { this.bean = bean; }
}
应用程序上下文.xml
<bean id="myNiceBean" class="com.exemple.DummyBean" />
和
public class MyClass {
private MyBean bean;
public MyBean getBean() { return bean; }
public void setBean(MyBean bean) { this.bean = bean; }
}
应用程序上下文.xml
<bean id="myNiceBean" class="com.exemple.DummyBean" />
<bean id="myClass" class="com.exemple.MyClass">
<property name="bean" ref="myNiceBean"/>
</bean>