目录
基于field注入
所谓基于field注入,就是在bean的变量上使用注解进行依赖注入。本质上是通过反射的方式直接注入到field。是平常开发中经常看到的一种方式,也是Spring团队所不推荐的方式,注解方式:
@Autowired
private Svc svc;
配置文件方式
//xml方式配置DI(基本类型)
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans