applicationContext.xml

    科技2024-07-08  71

    <?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:mvc="http://www.springframework.org/schema/mvc"     xmlns:context="http://www.springframework.org/schema/context"     xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"     xmlns:task="http://www.springframework.org/schema/task" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"     xsi:schemaLocation="http://www.springframework.org/schema/beans          http://www.springframework.org/schema/beans/spring-beans-4.0.xsd          http://www.springframework.org/schema/mvc          http://www.springframework.org/schema/mvc/spring-mvc-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         http://www.springframework.org/schema/task            http://www.springframework.org/schema/task/spring-task-4.0.xsd         http://code.alibabatech.com/schema/dubbo                 http://code.alibabatech.com/schema/dubbo/dubbo.xsd">

        <!-- 配置 读取properties文件 jdbc.properties -->     <context:property-placeholder location="classpath:jdbc.properties" />

        <!-- 配置 数据源 -->     <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">         <!-- 驱动 -->         <property name="driverClassName" value="${jdbc.driver}" />         <!-- url -->         <property name="url" value="${jdbc.url}" />         <!-- 用户名 -->         <property name="username" value="${jdbc.username}" />         <!-- 密码 -->         <property name="password" value="${jdbc.password}" />     </bean>          <!-- 配置SqlSessionFactory -->     <bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">         <property name="dataSource" ref="dataSource"/>         <!-- <property name="configLocation" value="classpath:mybatis-config.xml"/> -->         <!-- 配置pojo别名 -->         <property name="typeAliasesPackage" value="cn.shining.entity"></property>         <property name="mapperLocations" >             <list>                 <value>classpath:cn/shining/mapper/*.xml</value>             </list>         </property>     </bean>          <!-- 组件扫描-->     <context:component-scan base-package="cn.shining"/>           <!-- dao 包扫描 -->     <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">         <property name="basePackage" value="cn.shining.dao" />     </bean>

        <!-- 配置事务 -->     <!-- 事务管理器 -->     <bean id="transactionManager"         class="org.springframework.jdbc.datasource.DataSourceTransactionManager">         <!-- 数据源 -->         <property name="dataSource" ref="dataSource" />     </bean>

             <!-- 通知 -->     <tx:advice id="txAdvice" transaction-manager="transactionManager">         <tx:attributes>             <!-- 传播行为 -->             <tx:method name="save*" propagation="REQUIRED" />             <tx:method name="insert*" propagation="REQUIRED" />             <tx:method name="add*" propagation="REQUIRED" />             <tx:method name="create*" propagation="REQUIRED" />             <tx:method name="delete*" propagation="REQUIRED" />             <tx:method name="del*" propagation="REQUIRED" />             <tx:method name="update*" propagation="REQUIRED" />             <tx:method name="find*" propagation="SUPPORTS" read-only="true" />             <tx:method name="select*" propagation="SUPPORTS" read-only="true" />             <tx:method name="get*" propagation="SUPPORTS" read-only="true" />         </tx:attributes>     </tx:advice>               <!-- 切面 -->     <aop:config>         <aop:advisor advice-ref="txAdvice" pointcut="execution(* cn.shining.service..*.*(..))" />     </aop:config>     

    </beans>  

    Processed: 0.010, SQL: 8