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>
  • 相关阅读:
    spring boot actuator监控需要注意的点
    spring boot actuator端点高级进阶metris指标详解、git配置详解、自定义扩展详解
    3、尚硅谷_SSM高级整合_创建Maven项目.avi
    elasticSearch插件metricbeat收集nginx的度量指标
    elasticSearch插件的安装以及使用nginx的modles收集nginx的日志
    服务治理平台微服务介绍
    skywalking面板功能介绍2
    skywalking中表字段的信息
    js总结33 :javascript-DOM节点属性
    js教程系列32 :javascript-DOM节点操作
  • 原文地址:https://www.cnblogs.com/geng-geng1997/p/11358630.html
Copyright © 2011-2022 走看看