Spring入門筆記(二)

2021-07-01 19:57:33 字數 807 閱讀 2538

name=」 「>

local=」beanid」>

property>

name:屬性的名稱,setob() local=」beanid」:要被注入的id或name。

id屬性的值不能包含特定字元,如「/」,若想讓名字帶「/」,用name屬性來代替。

2 採用

name=」 「>

bean=」 「>

property>

ref local:只在當前文件中查詢被注入的id。 ref bean:會查詢所有的配置檔案。

3 將乙個bean的定義巢狀在另乙個bean中(可讀性差) 被巢狀的bean不能採用getbean()返回 例子**:

<?xml version="1.0" encoding="utf-8"?>

xmlns=""

xmlns:xsi=""

xsi:schemalocation=" /spring-beans-2.0.xsd">

id="otherbean"

class="ioc2.otherbean">

name="string1">

string1value>

property>

bean>

id="somebean"

class="ioc2.somebean">

name="ob">

local="otherbean"/>

property>

bean>

beans>

學習筆記 Spring入門(二)

六 bean 1 bean的配置項 id 整個ioc容器中該bean的唯一標識 class 具體例項化的類 scope 範圍 作用域 constructor arguments 構造器的引數 properties 屬性 autowriring mode 自動裝配的格式 lazy initializa...

Spring(二) Spring入門案例

service層的作用 在不改變dao層 的前提下,增加業務邏輯操作 public class studentserviceimpl implements studentservice 建立出dao層例項 存在耦合 studentdao dao new studentdaoimpl studentd...

spring入門筆記 beans

因為工作的原因接觸到了spring 希望勉勵自己堅持學下去。spring開發包。1.docs spring開發文件和api schema控制檔案的約束,lib中包含spring的jar。開始第乙個spring專案。建立乙個spring專案。從spring的lib資料夾下,講beans context...