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