day2:属性信息的注入
1.-----依赖注入----
关系注入
基本注入
集合注入
2.-----自动装配----
<bean>元素的autowire属性,可使用byName、byType、constructor等
3.-----注解应用------
注入注解:
a. @Autowired(required=false) @Qualifier("bean名称")
b. @Resource默认按照名称、之后按照类型@Resource(name="bean名称")
c. XML配置文件使用<context:annotation-config></context:annotation-config>
自动扫描
a. @Controller、@Service、@Repository、@Component
当容器将组件扫描后,组件对象的名称默认类名首字母小写,
也可以使用@Service("bean名称")
b. XML配置文件使用<context:component-scan base-package="tarena.annotation"/>
c. 使用范围和声明周期@Scope("singleton")、@PostConstruct、@PreDestroy