标签:public system autowire oid out 默认 启动 class color
@Autowired
标注在方法上@Autowired
public void setCar(Car car) {
this.car = car;
}
@Autowired
标注在构造器@Autowired
可以省略,也是自动从IOC容器中获取@Autowired
public Boss(Car car) {
this.car = car;
System.out.println("Boss 的有参构造器...");
}
@Autowired
标注在参数上@Autowired
public Boss(@Autowired Car car) {
this.car = car;
System.out.println("Boss 的有参构造器...");
}
@Bean
public Color color(@Autowired Car car) {
return new Color(car);
}
标签:public system autowire oid out 默认 启动 class color
原文地址:https://www.cnblogs.com/Grand-Jon/p/10040022.html