zoukankan      html  css  js  c++  java
  • SSM框架dao层和service层配置文件

    <?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:contexe="http://www.springframework.org/schema/context"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop.xsd">
    <!--dao层-->
    <!--引入外部文件-->
    <contexe:property-placeholder location="classpath:jdbc.properties"></contexe:property-placeholder>
    <!--链接数据源-->
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${jdbc.driver}"></property>
    <property name="url" value="${jdbc.url}"></property>
    <property name="username" value="${jdbc.user}"></property>
    <property name="password" value="${jdbc.password}"></property>
    </bean>
    <!--创建sqlsessionfaction对象-->
    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"></property>
    </bean>
    <!--扫描dao包 spring容器注入对象-->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="cn.dao"></property>
    </bean>
    <!--service层-->
    <!--扫描service层 开启service层注解-->
    <context:component-scan base-package="cn.service"></context:component-scan>
    <!--配置事务管理器-->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"></property>
    </bean>
    <!--事务处理 环绕-->
    <tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
    <tx:method name="find*" read-only="true" propagation="SUPPORTS"/>
    <tx:method name="get*" read-only="true" propagation="SUPPORTS"/>
    <tx:method name="query*" read-only="true" propagation="SUPPORTS"/>
    <tx:method name="*" read-only="false" propagation="REQUIRED"/>
    </tx:attributes>
    </tx:advice>
    <!--配置切面 面向service层-->
    <aop:config>
    <aop:advisor advice-ref="txAdvice" pointcut="execution(* cn.service.impl.*.*(..))"></aop:advisor>
    </aop:config>
    </beans>
  • 相关阅读:
    2013.11.3
    计算机面试书籍
    SDPLR的安装过程(matlab)
    Semi-definite programming优化工具
    R-note1
    Ubuntu---2
    C#中DataTable转换为string
    MFC获取字符串长度的5中方法
    根据不同的操作系统(64/32),设置文件以64位运行。又可解决问题:“试图加载不正确的程序”。
    WinServer2008下通过powershell获取IIS等角色功能列表,保存至txt
  • 原文地址:https://www.cnblogs.com/geng-geng1997/p/11358630.html
Copyright © 2011-2022 走看看