-
xml和注解都支持的初始化和銷毀方式:
查看全部 -
課程內(nèi)容筆記
查看全部 -
bean查看全部
-
IOC默認是單例模式,單例模式不需要重復(fù)new對象,這樣做的好處是用于解耦查看全部
-
通過注解方式開啟懶加載:
查看全部 -
Spring通過注解形式添加作用域:
查看全部 -
SpringIoC容器內(nèi)置接口實例注入:
查看全部 -
String、Integer等類型直接賦值:
查看全部 -
將多個泛型實例注入到List:
查看全部 -
直接注入List實例:
查看全部 -
通過指明要注入哪個Bean的id:
查看全部 -
通過屬性直接注入Bean:
@Component public?class?MyBean{ ????@Autowired//通過屬性直接注入bean ????private?AnotherBean?anotherBean; ???? ????public?AnotherBean?getAnotherBean(){return?anotherBean;} ???? ????public?void?setAnotherBean(AnotherBean?anotherBean){ ????????this.anotherBean?=?anotherBean; ????} }
查看全部 -
通過構(gòu)造方法和Set方法注入Bean:
@Component public?class?MyBean{ ????private?AnotherBean1?anotherBean1; ????private?AnotherBean2?anotherBean2; ????@Autowired//通過構(gòu)造方法注入bean ????public?MyBean(AnotherBean1?anotherBean1){this.anotherBean1?=?anotherBean1;} ????public?AnotherBean2?getAnotherBean2(){return?anotherBean2;} ????@Autowired//通過set方法注入bean ????public?void?setAnotherBean2(AnotherBean2?anotherBean2){this.anotherBean2?=?anotherBean2;} ?}
查看全部 -
注入bean
查看全部 -
Bean別名指定的兩種方式(.xml文件,注解):
查看全部
舉報
0/150
提交
取消