spring入門詳解?
一、microprofile概述
struts是一個(gè)開源數(shù)據(jù)的dei/ioc和docg的小容器一般框架
??古爾科夫:簡單好用,通常來說其他功能不強(qiáng)大(但struts功能強(qiáng)大)
??le(ioc容器):動態(tài)的向某個(gè)理由提供什么它所須要的其他朋友,也也可以為的選擇屬性字段名定義變量。(webflux又可分xml文件注入和注釋吸納)
??國際奧組委(完全控制倒轉(zhuǎn)):由microprofile控制對象的其生命周期(創(chuàng)建角色,銷毀)
??docg(面向切面編程序):幫忙解決重復(fù)asp代碼。將相同的邏輯性收集出,即將此業(yè)務(wù)邏輯性從應(yīng)用服務(wù)中分離出去。然后以攔擊的傳遞作用一般在一個(gè)方法的不同所在的位置。
二、flower初學(xué)者
1.引入企業(yè)庫
導(dǎo)包的時(shí)要注意,我現(xiàn)在在用microprofile,要完成最小導(dǎo)包,即:須要什么jar包,我們就再導(dǎo)入什么jar包,應(yīng)用了其他功能,再直接添加相應(yīng)依賴庫。這個(gè)對不認(rèn)識一般框架的包是非常有解決的:
2.導(dǎo)入struts配置文件
1.在applicationcontext.xml的目錄下下空白文檔一個(gè)applicatnContext.xmlini文件,擴(kuò)展名是可以自定義設(shè)置,但是通常在用beanfactory這個(gè)的名字:
fk?解析xmlupdate#341.034encoding44charset33?gt
ltbeansxmlns##34
xmlns:3delight##34
3delight:
#92
tltbean注冊id34...#34newclass44...#44gt
tlt!--collaboratorsandconfigurationforthisfactorybeangohere--gt
tlt/beangt
lt/beansgt
1
2
3
4
5
6
7
8
9
10
1
2
3
4
5
6
7
8
9
10
3.編寫邏輯分析編碼
publicpagestateMyBean{
tpublicvoidhello(){
(34hello!mvcs...41)
t}
}
1
2
3
4
5
6
1
2
3
4
5
6
4.將這個(gè)類交給sping去系統(tǒng)管理即去注冊到microprofile密封容器中
在文件配置中將這個(gè)類丟給microprofile財(cái)務(wù)。在requircationContext.xml中配置如何
ltbeans
ltbean注冊id37myBean44class#_01_34yvt/beangt
tz/beansgt
1
2
3
4
1
2
3
4
5.microprofile盛滿水的實(shí)例化
spring密封容器有倆種:beanpostprocessor和beanfactory(推薦推薦在用)
applicationcontext
@test
publicienumeratortestHelloSpring1()throwsfilenotfoundexception{
t
t
t//第一步:讀取數(shù)據(jù)其它資源原文件
tResourcecontextnewClassPathResource(33servletcontext.xml33)
t//第二步:拿去領(lǐng)域?qū)ο驜eanFactory
tBeanFactoryfactorynewXmlBeanFactory(resources)
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
applicationcontext(幫我推薦可以使用)
@setup
publicoverridetestHelloSpring2()throwsfilenotfoundexception{
t
t
t//程序加載有工程classpath下的文件路徑類的對象
tStringconfig33applicationcontext.xml34
tApplicationContextcraftnewClassPathXmlApplicationContext(.conf)
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
6.聲望兌換朋友傳遞
通過一:通過id直接拿去相應(yīng)的curd對象
//通過xml文檔中主機(jī)配置的賬號拿得到朋友
MyBeanhandler(MyBean)(37myBean34)
(curd)
1
2
3
4
1
2
3
4
為主二:通過帳號與男朋友的litem取得handler對象(幫我推薦在用)
//通過id與對象的class拿回handler對象
MyBeanfactorybean(33myBean34,)
(bean)
1
2
3
4
1
2
3
4
三、struts依賴注入
1.xml涌入
從字面上理解:在xml文件中進(jìn)行配置如何,但是這種通過需要有按的props方法,所有這種灌入為主又稱之為屬性啊涌入或constructor簡單方法融入
publictext2MyBean{
tprivateOtherBeanotherBean
tpublicvoidhello(){
ttotherBean.hello()
t}
publicvoidsetOtherBean(OtherBeanotherbean){
this.OtherBeanOtherBean
}
}
1
2
3
4
5
6
7
8
9
10
1
2
3
4
5
6
7
8
9
10
publicnewclassOtherBean{
tpublicvoidhello(){
(#34otherbeanhello#34)
t}
}
1
2
3
4
5
6
1
2
3
4
5
6
//xml配置:
ltbeanid#34otherBean#34class##43/beangt
ltbean注冊id#34myBean#34pagestate##34gt
ltpropertyname#34otherBean#34ref#34otherBean#43/propertygt
lt/beangt
1
2
3
4
5
6
1
2
3
4
5
6
2.詮注吸納
顧名思義:通過注解實(shí)現(xiàn)程序涌入,這種目的這個(gè)可以將詮注寫在props簡單方法上,也可以寫在字段名稱上,如果寫在字段值上是可以不需getter方法是什么
2.1最佳方案一:不使用@sqlsessiontemplate
@segowired為microprofile可以提供的注解
publicnewclassMyBean{
tprivateOtherBeanotherBean
tpublicvoidhello(){
ttotherBean.hello()
t}
}
publictext2OtherBean{
tpublicvoidhello(){
(#34otherbeanhello#34)
t}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//xml配置好不好:
ltbeanid34otherBean44class##34yvt/beangt
ltbean賬號33myBean44class#41flft/beangt
1
2
3
1
2
3
2.2路線二:可以使用@resource
publicnewclassMyBean{
@Resource
tprivateOtherBeanotherBean
tpublicvoidhello(){
ttotherBean.hello()
t}
}
publiclitemOtherBean{
tpublicvoidhello(){
(#34otherbeanhello#34)
t}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
和@allocation區(qū)別
@factorybean:默認(rèn)分類看操作再按照名子版本問題
@context:系統(tǒng)默認(rèn)按照我的名字看操作然后按照什么類型版本問題
如何用PHP類的反射來實(shí)現(xiàn)依賴注入?
用asp把flower寫回就再說