學習 Spring 2 5 的新特性,第一部分

2021-08-22 14:02:50 字數 1042 閱讀 9446

學習 infoq 的《spring 2.5 的新特性:第一部分》。[url=原文[/url]

這篇文章講的是 spring 2.5 新加入的 annotation 部分的內容。下面說說我的感受。

這次 spring 2.5 新加入的 annotation 分為兩種,一種是 jsr-250 的公共 annotation,另一種是 spring 自有 annotation。

[b]jsr-250 annotation:[/b] 使用這些 annotation 必須在配置檔案裡加入乙個 spring post-processor。

[list]

[*]@resource: 這個 annotation 的作用就是提供了用 annotation 的方式注入資源,不必在 xml 配置檔案中顯示宣告了。還支援根據屬性名或屬性的型別進行自動的注入。

[*]@postconstruct: 這個 annotation 感覺暫時用不到(對我來說),所以沒有細看。有興趣的可以看原文。

[*]@predestroy: 同上。

[/list]

[b]spring 2.5 自有的 annotation[/b]:

[list]

[*]@autowired: 這個 annotation 支援更為靈活的注入。

@autowired

public void setup(datasource datasource, anotherobject o)

[*]@qualifier: 也是用於細粒度注入的。

[*]@service 和 @controller: 這個好理解,不多說。反正我感覺這倆是不錯東西,做專案的時候在仔細體會吧。

[*]@scope: 就是 spring 2.0 加入的 scope 屬性的 annotation。

[/list]

總結:還有一些原文介紹過的 annotation 沒有介紹,主要原因我沒大看懂。我覺得這篇文章寫的不太好,很多東西介紹的不清楚。想要具體學習 spring 2.5 的新特性還是看 spring 提供的例子比較好(我還沒有看過,有時間學習下)

spring2 5的乙個新特性

今天在學習spring2.5的乙個新特性,感覺很方便。spring自動掃瞄和管理bean 先來看看beanx.xml xml version 1.0 encoding utf 8 xmlns context xsi schemalocation spring beans 2.5.xsd spring...

Spring2 5中bean定義的繼承

在bean定義中包含了大量的配置資訊,其中包括容器相關的資訊 比如初始化方法 靜態工廠方法等 以及構造器引數和屬性值。子bean定義就是從父bean定義繼承配置資料的bean定義。它可以覆蓋父bean的一些值,或者新增一些它所需要的值。使用父子bean定義的方式可以節省很多的輸入工作。實際上,它是一...

spring5 5的新特性

官擋 版本5.0.5.release 歡迎使用spring framework參考文件!請閱讀概述以獲取簡要介紹,包括簡要歷史記錄,設計理念,提問位置以及入門提示。有關 新增功能 或 從 早期版本遷移 的資訊,請檢視 github wiki 參考文件分為幾個部分 核心ioc容器,事件,資源,國際化,...