1. 程式人生 > >Spring 進階一

Spring 進階一

使用 pan 案例 lns com new task logs idt

Spring 進階一

技術分享圖片

以前創建對象都是通過new的方式

技術分享圖片

Spring提出新的方案

Ioc底層的原理和使用技術

一:xml配置

二:Dom4j解析xml

三:工程的設計模式

四:反射

技術分享圖片

Ioc入門案例

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.0.xsd





</beans>

通過配置文件創建對象

技術分享圖片

class為創建對象類的全路徑

技術分享圖片

xml文件提示

技術分享圖片

對象創建的三種方式

技術分享圖片

第二種技術分享圖片技術分享圖片

第三種技術分享圖片技術分享圖片

Factory-method 為方法名

09-bean標簽常用屬性(idclassname

技術分享圖片

技術分享圖片

11-屬性註入介紹

技術分享圖片

Spring框架只支持前面兩種方式

構造方式 技術分享圖片技術分享圖片

打印結果

技術分享圖片

Set註入

技術分享圖片

技術分享圖片

set註入對象

技術分享圖片

15-註入復雜類型屬性

P命名空間註入 還有很多比較復雜的註入 如 數組 list map。。。

技術分享圖片

IocdI的區別

技術分享圖片

Spring 進階一