Spring applicatoincontest.xml 配置
来源:互联网 发布:淘宝刷好评多少钱一个 编辑:程序博客网 时间:2024/06/08 19:38
spring配置:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"> <!-- 开启注解处理器 --> <context:annotation-config /> <!-- 开户组件自动扫描 扫描 service,dao --> <context:component-scan base-package="com.duanrong.drproject.business.*.service, com.duanrong.drproject.business.*.dao" /> <!-- 开启基于@AspectJ切面的注解处理器 --> <aop:aspectj-autoproxy /> <!-- 由于class属性指定的类的默认构造方法创建一个单实例bean,名称由id属性指定 --> <bean id="Bean的实例名称" class="Bean类全名" /> <!-- scope属性为prototype时表示每次生成一个新的实例,即原型模式 --> <bean id="Bean的实例名称" class="Bean类全名" scope="prototype" /> <!--init-method属性指定对象实例化后要调用的初始方法; destroy-method属性指定对象销毁时要调用的方法--> <bean id="Bean的实例名称" class="Bean类全名" init-method="初始化时调用的方法名" destroy-method="对象销毁时调用的方法名" /> <!-- property标签用于对bean实例中的属性进行赋值,对于基本类型的属性值可以直接指定;而ref则是对其它bean实例的引用 --> <bean id="Bean的实例名称" class="Bean类全名"> <property name="Bean类中的属性名称" ref="要引用的bean名称"/> <property name="Bean类中的属性名称" value="直接指定的属性值"></property> <property name="Bean类中的属性名称"> <bean class="bean类全名"></bean> <!-- 创建一个内部匿名bean实例赋值给指定的属性,该匿名bean实例无法被外界访问 --> </property> <!-- set标签用于创建一个set类型实例赋值给set类型的属性,set实例中的元素通过value或ref子标签指定。对于基本 类型的元素可由value标签生成;如果需要引用其它bean实例做为set元素的话可由ref标签指定 --> <property name="Bean类中set类型的属性名称"> <set> <value>set中的元素</value> <ref bean="要引用的bean名称"/> </set> </property> <!--list标签用于创建一个list类型实例赋值给List类型的属性,list实例中的元素通过value或ref子标签指定。对于 基本类型的元素可由value标签生成;如果需要引用其它bean实例做set元素的话可以ref标签指定 --> <property name="Bean类中List类型的属性名称"> <list> <value>list中的元素</value> <ref bean="要引用的bean名称"/> </list> </property> <!--map标签用于创建一个map类型实例赋值给map类型的属性,map实例中的元素通过entry标签指定,map元素的key由entry标签的 key属性直接指定,值由于value或ref子标签指定。对于 基本类型的元素可由value标签生成;如果需要引用其它bean实例做set元素的话可以ref标签指定 --> <property name="bean类中的map类型属性"> <map> <entry key="map元素的key"> <value>map元素的value</value> </entry> <entry key="map元素的key"> <ref bean="要引用的bean名称"/> </entry> </map> </property> <!-- 给propertiest类型的属性赋值 --> <property name="bean类中properties类型属性名称"> <props> <prop key="properties元素的key">properties元素的value</prop> </props> </property> <!-- 给指定属性赋值为 null --> <property name="bean类中要初始化为null的属性名称"> <null/> </property> </bean> <!-- 通过传入相应的构造进行bean实例化,constructor-arg标签用于指定一个构造参数,其中index属性用于指定其为 第几个构造参数(从0开始 ),type属性申明构造参数的类型,构造参数的值由于value或ref属性指定 --> <bean id="bean实例名称" class="bean类全名"> <constructor-arg index="从0开始的序号" type="构造参数的类型" value="构造参数的值"/> <constructor-arg index="从0开始的序号" type="构造参数的类型" ref="要引用的bean名称"></constructor-arg> </bean> <aop:config> <aop:aspect id="切面id" ref="要引用的切面实例名称"> <aop:pointcut expression="切入点正则表达示" id="切入点名称"/> <aop:before method="切面类中用于前置通知的方法名称" pointcut-ref="切入点名称"/>、 <aop:after-returning method="切面类中用于后置通知的方名称" pointcut-ref="切入点名称"/> <aop:after-throwing method="切面类中用于异常通知的方法名称" pointcut-ref="切入点名称"/> <aop:after method="切面类中用于最终通知的方法名称" pointcut-ref="切入点名称"/> <aop:around method="切面类中用于环绕通知的方法名称" pointcut-ref="切入点名称"/> </aop:aspect> </aop:config> <!-- 配置事物管理器 --> <bean id="事物管理器实例名称" class="事物管理器类全名"> <property name="数据源属性名称" ref="要引用的数据源实例名称"></property> </bean> <!-- 配置一个事物通知 --> <tx:advice id="事物通知名称" transaction-manager="事物管理器实例名称"> <tx:attributes> <!-- 方法以get开头的不用事务 --> <tx:method name="get*" read-only="true" propagation="NOT_SUPPORTED"/> <!-- 其他方法以默认事务进行 --> <tx:method name="*"/> </tx:attributes> </tx:advice> <!-- 使用aop方法技术实现事务管理 --> <aop:config> <aop:pointcut expression="事物切入点正则表达式" id="事物切入点名称"/> <aop:advisor advice-ref="事物通知名称" pointcut-ref="事物切入点名称"/> </aop:config></beans>
阅读全文
0 0
- Spring applicatoincontest.xml 配置
- Spring XML配置技巧
- Spring XML配置技巧
- spring读取xml配置
- spring applicationContext.xml配置
- Spring XML配置总结
- Spring xml事务配置
- Spring中多个.xml配置
- 最小化Spring XML配置
- 基于xml配置spring
- XML基础知识-->Spring配置
- Spring、XML配置AOP
- XML配置Spring注解
- spring applicationContext.xml配置
- Spring xml配置实例
- spring.xml配置
- cassndra spring.xml配置
- 最小化Spring XML配置
- java编程思想笔记-并发之线程协作(四)
- 产品设计,应不应该追求高保真?
- webuploader 分片上传时 保存信息的java类
- ARM与X86 CPU架构对比区别
- PopupWindow+spinner使用方法
- Spring applicatoincontest.xml 配置
- spark2.2内核剖析---checkpoint与presist
- api url
- bzoj4917: Hash Killer IV
- 高并发网络连接数因端口数量受限问题
- Android零基础入门第31节:几乎不用但要了解的AbsoluteLayout绝对布局
- java 集合 容器 List Set Map区别
- 按照文件路径和文件名创建文件夹及下载文件的一些总结
- WPF 实现新手指引功能 DEMO