Spring|Bean的初始化、作用域
BeanDefaintion 保存 Bean 的元信息,是 Bean 的“配料表”。
Bean 初始化的方式:
1、通过构造器除时候( 不可变对象)
public class SimpleMovieLister {
// the SimpleMovieLister has a dependency on a MovieFinder
private MovieFinder movieFinder;
// a constructor so that the Spring container can inject a MovieFinder
public SimpleMovieLister(MovieFinder movieFinder) {
this.movieFinder = movieFinder;
}
// business logic that actually uses the injected MovieFinder is omitted...
}