zoukankan      html  css  js  c++  java
  • spring整合mybatis配置文件

    <?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:jdbc="http://www.springframework.org/schema/jdbc"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
    http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
    http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
    http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">
    <!-- 配置组件扫描 -->
    <context:component-scan base-package="service,dao,controller,entity,util,aop"></context:component-scan>
    <!-- 配置mvc注解扫描 -->
    <mvc:annotation-driven></mvc:annotation-driven>

    <!-- 开启AOP注解标记 -->
    <aop:aspectj-autoproxy></aop:aspectj-autoproxy>
    <!--AOP配置,可用注解

      <aop:config>
      关联REF组件类
      <aop:aspect ref="loggerBean">
      <aop:before method="logController" pointcut="within(controller..*)"/>
      </aop:aspect>

      方法限定类型
      <aop:aspect ref="loggerBean">
      前置通知
      <aop:before method="logController" pointcut="execution(* controller..*(..))"/>
      后置通知
      <aop:after-returning method=""/>
      异常通知
      <aop:after-throwing method=""/>
      最终通知
      <aop:after method=""/>
      @around=环绕通知(前置+后置通知)
      </aop:aspect>
      </aop:config>
    -->
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dbcp"></property>
    </bean>

    <tx:annotation-driven transaction-manager="txManager"/>

    <util:properties id="config" location="classpath:conf/mysql.properties"></util:properties>
    <bean id="dbcp" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
      <property name="driverClassName" value="#{config.driverClassName}"></property>
      <property name="url" value="#{config.url}"></property>
      <property name="username" value="#{config.username}"></property>
      <property name="password" value="#{config.password}"></property>
    </bean>
    <!-- 配置SqlSessionFactoryBean -->
    <bean id="ssfb" class="org.mybatis.spring.SqlSessionFactoryBean">
      <property name="dataSource" ref="dbcp"></property>
      <property name="mapperLocations" value="classpath:mapper/*.xml"></property>
    </bean>
    <!-- MapperScannerConfigurer扫描指定包下的mapper映射器,本质是调用SqlSession的getMapper()
    还会降这些对象添加到spring容器,(默认id是首字母小写之后的接口名,也可使用@Respository来设置id) -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
      <property name="basePackage" value="dao"></property>
      <!-- <property name="annotationClass" value="dao.annotation.MyBatisRepository"></property> -->
    </bean>

    </beans>

  • 相关阅读:
    z-index只能在position属性值为relative或absolute或fixed的元素上有效。
    margin负值得理解
    <em>标签与<strong>标签区别
    文字的垂直居中
    data-*的定义和用法
    one()方法的介绍
    <meta name="application-name" content="优酷网" /> 是什么意思?
    <meta property="qc:admins" content="70003766576320416375" />是什么意思?具体功能是什么?
    head部分关于搜索引擎
    java第三次作业
  • 原文地址:https://www.cnblogs.com/xyz23/p/6343271.html
Copyright © 2011-2022 走看看