spring配置文档Word格式.docx

上传人:b****6 文档编号:21979590 上传时间:2023-02-02 格式:DOCX 页数:11 大小:18.07KB
下载 相关 举报
spring配置文档Word格式.docx_第1页
第1页 / 共11页
spring配置文档Word格式.docx_第2页
第2页 / 共11页
spring配置文档Word格式.docx_第3页
第3页 / 共11页
spring配置文档Word格式.docx_第4页
第4页 / 共11页
spring配置文档Word格式.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

spring配置文档Word格式.docx

《spring配置文档Word格式.docx》由会员分享,可在线阅读,更多相关《spring配置文档Word格式.docx(11页珍藏版)》请在冰豆网上搜索。

spring配置文档Word格式.docx

//www.springframework.org/schema/beans/spring-beans-2.5.xsd

//www.springframework.org/schema/context

//www.springframework.org/schema/context/spring-context-2.5.xsd

"

context:

component-scanbase-package="

com.persia"

!

--开启组件扫描-->

/context:

component-scan>

annotation-config>

--开启注解处理器-->

--使用注解,省去了propertity的xml配置,减少xml文件大小-->

beanid="

personServiceAnno"

class="

com.persia.PersonServiceAnnotation"

/bean>

personDaoBeanAnno"

com.persia.PersonDaoBean"

personDaoBeanAnno2"

--自动注解-->

personServiceAutoInject"

com.persia.PersonServiceAutoInject"

autowire="

byName"

personService"

com.persia.PersonServiceBean"

--由spring容器去创建和维护,我们只要获取就可以了-->

personService2"

com.persia.PersonServiceBeanFactory"

factory-method="

createInstance"

lazy-init="

true"

init-method="

init"

destroy-method="

destory"

--静态工厂获取bean-->

fac"

com.persia.PersonServiceBeanInsFactory"

personService3"

factory-bean="

scope="

prototype"

--实例工厂获取bean,先实例化工厂再实例化bean-->

--ref方式注入属性-->

personDao"

personService4"

<

propertyname="

ref="

/property>

--内部bean方式注入-->

personService5"

beanclass="

name"

value="

persia"

age"

21"

sets"

--集合的注入-->

set>

value>

第一个<

/value>

第二个<

第三个<

/set>

lists"

list>

第一个l<

第二个l<

第三个l<

/list>

properties"

props>

propkey="

key1"

value1<

/prop>

key2"

value2<

key3"

value3<

/props>

map"

map>

entrykey="

value-1"

/entry>

value-2"

value-3"

/map>

personService6"

constructor-argindex="

0"

构造注入的name"

>

/constructor-arg>

--基本类型可以不写type-->

1"

type="

com.persia.IDaoBean"

/beans>

 

2.开启AOP:

aop="

//www.springframework.org/schema/aop"

//www.springframework.org/schema/aop

//www.springframework.org/schema/aop/spring-aop-2.5.xsd

aop:

aspectj-autoproxy>

/aop:

myInterceptor"

com.persia.service.MyInterceptor"

personServiceImpl"

com.persia.service.impl.PersonServiceImpl"

AOP的xml版本<

aspectBean"

config>

aspectid="

myaop"

pointcutid="

mycut"

expression="

execution(*com.persia.service.impl.PersonServiceImpl.*(..))"

/>

argcut"

execution(*com.persia.service.impl.PersonServiceImpl.*(..))andargs(name)"

beforepointcut-ref="

method="

doAccessCheck"

/>

after-returningpointcut-ref="

doAfterReturning"

after-throwingpointcut-ref="

doThrowing"

afterpointcut-ref="

doAfter"

arg-names="

aroundpointcut-ref="

arround"

aspect>

3.开启事务和注解:

tx="

//www.springframework.org/schema/tx"

//www.springframework.org/schema/txhttp:

//www.springframework.org/schema/tx/spring-tx-2.5.xsd

--配置数据源-->

dataSource"

mons.dbcp.BasicDataSource"

close"

driverClassName"

com.mysql.jdbc.Driver"

url"

jdbc:

mysql:

//localhost:

3306/test?

useUnicode=true&

amp;

characterEncoding=utf-8"

username"

root"

password"

"

--连接池启动时的初始值-->

initialSize"

--连接池的最大值-->

maxActive"

500"

--最大空闲值.当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止-->

maxIdle"

2"

--最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请-->

minIdle"

--配置事务管理器-->

txManager"

org.springframework.jdbc.datasource.DataSourceTransactionManager"

--配置业务bean-->

ds"

--采用@Transactional注解方式来使用事务-->

tx:

annotation-driventransaction-manager="

XML版本:

--配置事务管理器-->

--使用XML来使用事务管理-->

--配置一个切面,和需要拦截的类和方法-->

transactionPointcut"

execution(*com.persia.service..*.*(..))"

advisoradvice-ref="

txAdvice"

pointcut-ref="

--配置一个事务通知-->

adviceid="

transaction-manager="

attributes>

--方法以get开头的,不使用事务-->

methodname="

get*"

read-only="

propagation="

NOT_SUPPORTED"

--其他方法以默认事务进行-->

*"

/tx:

advice>

4.SSH:

//www.springf

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 总结汇报 > 工作总结汇报

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1