Spring配置(含事务)

来源:互联网 发布:网络搜索引擎的文章 编辑:程序博客网 时间:2024/05/17 00:51

<?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:jee="http://www.springframework.org/schema/jee"
       xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"
       default-lazy-init="false" default-autowire="byName">
    <description>Spring公共配置文件</description>
  
    <!-- 定义受环境影响易变的变量 -->
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
        <property name="ignoreResourceNotFound" value="true"/>
        <property name="locations">
            <list>
                <value>classpath:application.properties</value>
                <!--定义core的一些变量-->
                <value>classpath:core.properties</value>              
            </list>
        </property>
    </bean>

    <!-- 使用annotation 自动注册bean,并检查@Required,@Autowired的属性已被注入 -->
    <context:component-scan base-package="com.weimei.ctmarket.manager"/>
       
    <!-- 数据源 -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${manager.driver}"/>
        <property name="url" value="${manager.url}"/>
        <property name="username" value="${manager.username}"/>
        <property name="password" value="${manager.password}"/>
    </bean>
   
    <!-- 事务  -->
    <bean id="transactionManager"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
         <property name="dataSource" ref="dataSource"/>
    </bean>
   
    <!-- 事务AOP-->
    <aop:config proxy-target-class="true">
        <aop:advisor pointcut="execution(* com.weimei.*.impl.*ServiceImpl.*(..))" advice-ref="txAdvice"/>
    </aop:config>

    <tx:advice id="txAdvice" transaction-manager="transactionManager">
        <tx:attributes>
            <tx:method name="save"/>
            <tx:method name="save*"/>
            <tx:method name="modify"/>
            <tx:method name="modify*"/>
            <tx:method name="remove"/>
            <tx:method name="remove*"/>
            <tx:method name="delete"/>
            <tx:method name="delete*"/>
            <tx:method name="update"/>
            <tx:method name="update*"/>
            <tx:method name="insert"/>
            <tx:method name="insert*"/>
            <tx:method name="add"/>
            <tx:method name="add*"/>
            <tx:method name="*" read-only="true"/>
        </tx:attributes>
    </tx:advice>
   
    <!-- 使用annotation定义事务 -->
    <!-- 
    <tx:annotation-driven transaction-manager="transactionManager"/>
 -->
 <tx:annotation-driven transaction-manager="transactionManager"/>
 
    <!--MA sqlmapclient-->
    <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
        <property name="configLocation" value="classpath:sqlmap/sqlmap-config.xml"/>
    </bean>
   
    <!-- 导入协议包支持 -->
 <import resource="classpath*:spring-protocol.xml"/>
 
    <!--放置后台管理的dao和service-->   
    <import resource="classpath*:dao/*-dao.xml"></import>   
    <import resource="classpath*:service/ap/*-service.xml"></import>
    <import resource="classpath*:service/msp/*-service.xml"></import>
    <import resource="classpath*:service/sp/*-service.xml"></import>
    <import resource="classpath*:api/admin/*-service.xml"></import>
   <import resource="classpath*:api/*-service.xml"></import>
   <import resource="classpath*:api/msp/*-service.xml"></import>
   <import resource="classpath*:api/sp/*-service.xml"></import>
</beans>

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 云株花叶子发黄怎么办 驱蚊草叶子发黄怎么办 多肉叶子有黑点怎么办 多肉植物干瘪了怎么办 多肉叶片有黑点怎么办 多肉叶片有黑斑怎么办 多肉表面有黑点怎么办 杉果游戏买了后怎么办 盆景叶子上的灰怎么办 福建茶盆景掉叶怎么办 被普通蜘蛛咬了怎么办 被小蜘蛛咬了怎么办 被一般蜘蛛咬了怎么办 联通4g流量超出怎么办 腿上的肥胖纹怎么办除 金属眼镜腿歪了怎么办 炸东西油往外溢怎么办 油反复使用起沫怎么办 炸东西的油黑了怎么办 板栗放久了干了怎么办 三四个月的宝宝拉肚子怎么办 四个月的孩子拉肚子怎么办 4个月孩子拉肚子怎么办 三阳的房子很热怎么办 买了缺角的房子怎么办 多肉摇钱树焉了怎么办 虎皮兰叶子烂了怎么办 三角龙骨烂根了怎么办 地板木龙骨会动怎么办 多肉植物开花后怎么办 春峰之辉烂了怎么办 仙人指不开花是怎么办 大门开在破财位怎么办 人走霉运的时候怎么办 pp助手刷机失败怎么办 别人骂我很难听怎么办 被骂了心里不爽怎么办 被别人扎小人了怎么办 人要倒霉的时候怎么办 属虎的请了貔貅怎么办 我的护身符丢了怎么办