这是我的示例bean:
@Component
public class FirstBean {
private List<String> foo;
// Getters and Setters
}
现在我想将foo
列表从FirstBean
连接到SecondBean
bean。像这样或者可能在XML配置文件中:
@Component
public class SecondBean {
@Autowired
private List<String> foo
}
如何连接bean的引用对象而不是bean本身?
谢谢!
答案 0 :(得分:0)
您可以按照以下步骤操作:
@Component
public class TheList {
private List<String> theList;
}
@Component
public class FirstBean {
@Autowired
private TheList foo;
}
@Component
public class SecondBean {
@Autowired
private TheList foo;
}