學習目標:通過factorybean配置bean
factorybean是spring提供的乙個bean,裡面有三個方法
org.springframework.beans.factory.factorybean.getobject()
org.springframework.beans.factory.factorybean.getobjecttype()
org.springframework.beans.factory.factorybean.issingleton()
建立乙個car類
public
class car
public
void
setbrand(string brand)
public
double
getprice()
public
void
setprice(double price)
@override
public string tostring()
public
car()
public
car(string brand, double price)
建立乙個ca***ctorybean實現factorybean;
public
class
ca***ctorybean
implements
factorybean
@override
public object getobject() throws exception
//返回bean的型別
@override
public class getobjecttype()
@override
public
boolean
issingleton()
配置檔案
class="com.atguigu.spring.beans.factorybean.ca***ctorybean">
name="brand" value="奧迪">property>
factorybean來配置bean的例項
class:指向factorybean的全類名
property配置factorybean的屬性
實際返回的例項確實factorybean的getobject()方法返回的例項!
spring課程學習 1,2課
第一課 junit測試相關講解 1.junit使用 junit 測試組合 即把所有的alltest都包在總的alltest裡面,而每乙個不同的包裡的alltest又包含各自包裡所有的測試,故一次就能執行所有的測試。這種suite的實際模式實際上就是組合模式。用mock物件進行測試 3.對遺留 進行測...
學習筆記12
sql server提供了兩種索引 聚集索引和非聚集索引。其中聚集索引表示表中儲存的資料按照索引的順序儲存,檢索效率比非聚集索引高,但對資料更新影響較大。非聚集索引表示資料儲存 在乙個地方,索引儲存在另乙個地方,索引帶有指標指向資料的儲存位置,非聚集索引檢索效率比聚集索引低,但對資料更新影響較小。聚...
spring學習筆記
spring中兩個十分重要的概念 ioc di aop 1.ioc di inverse of control dependence injection ioc 控制反轉,看起來比較牛b,說起來十分簡單。就是不使用傳統的將類的依賴關係用硬編碼來維護的方式,而是讓容器來管理類之間的依賴,依賴關係在全在...