日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Spring点滴二:Spring Bean

發布時間:2024/1/17 javascript 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring点滴二:Spring Bean 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Spring Bean:

?? 被稱作bean的對象是構成應用程序的支柱,是由Spring Ioc容器管理。bean是一個被實例化,配置、組裝并由Spring Ioc容器管理對象。

?? 官網API:A Spring IoC container manages one or more beans. These beans are created with the configuration metadata that you supply to the container, for example, in the form of XML <bean/> definitions.

?? 翻譯:一個Spring IoC容器管理一個或多個beans。這些benas的創建是由配置元數據提供到容器里。例如:XML 表單中<bean>的定義

?

<?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/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd"><!-- 定義一個bean --><bean id="...." class="...."></bean> </beans>

<bean>標簽包含屬性詳解:

?id/name?用來指定bean唯一標識符,在基于XML配置元數據中,通過id或那么來指定bean唯一標識符    
?class?該屬性是強制性的,用來指定bean所對應的Java POJO類
?scope?用來指定bean對象的作用域
?constructor-arg?用來注入依賴關系的
?properties?用來注入依賴關系的
?autowiring mode?用來注入依賴關系的
?lazy-initialization mode?該bean是延遲初始化的,告訴Spring容器該bean不是在容器啟動時初始化的而是第一次被請求時才初始化
?initialization 方法?該bean被初始化時要調用的方法
?destruction 方法?該bean被銷毀時要調用的回調方法

?

   

?

?

?

?

?

?

?

?

?

這個配置文件中有不同的 bean 定義,包括延遲初始化,初始化方法和銷毀方法的:

<?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/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd"><!-- A simple bean definition --><bean id="..." class="..."><!-- collaborators and configuration for this bean go here --></bean><!-- A bean definition with lazy init set on --><bean id="..." class="..." lazy-init="true"><!-- collaborators and configuration for this bean go here --></bean><!-- A bean definition with initialization method --><bean id="..." class="..." init-method="..."><!-- collaborators and configuration for this bean go here --></bean><!-- A bean definition with destruction method --><bean id="..." class="..." destroy-method="..."><!-- collaborators and configuration for this bean go here --></bean><!-- more bean definitions go here --></beans>

?

   

轉載于:https://www.cnblogs.com/sishang/p/6565546.html

總結

以上是生活随笔為你收集整理的Spring点滴二:Spring Bean的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。