• ssm的beans.xml配置


    <?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:tx="http://www.springframework.org/schema/tx"
    	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-4.0.xsd
    		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
     <!-- 配置扫描包  -->
        <context:component-scan base-package="com.offcn" >
         <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
         <context:exclude-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/>
        </context:component-scan>
        
        <!-- 加载properties配置文件 -->
        <context:property-placeholder location="classpath:jdbc.properties"/>
        <!-- 配置数据源  -->
        <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
    		<property name="username" value="${jdbc.userName}"></property>
    	    <property name="password" value="${jdbc.password}"></property>
    		<property name="url" value="${jdbc.jdbcUrl}"></property>
    		<property name="driverClassName" value="${jdbc.driverClass}"></property>
        </bean>
        
        
        <!-- 配置数据源事务管理器  -->
        <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
          <property name="dataSource" ref="dataSource"></property>
        </bean>
        
        <!-- Spring整合MyBatis以下两步  -->
         <!-- 加载mybatis全局配置文件,生成sqlSessionFactory对象 -->
        <bean class="org.mybatis.spring.SqlSessionFactoryBean">
          <property name="dataSource" ref="dataSource"></property>
          <property name="configLocation" value="classpath:mybatis-config.xml"></property>
        </bean>
        
        <!-- 配置Mapper接口 -->
        <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
          <property name="basePackage" value="com.offcn.dao"></property>
        </bean>
        
        
        <!-- 开启基于注解的事务支持 -->
        <tx:annotation-driven transaction-manager="transactionManager"/>
    
    </beans>
    
  • 相关阅读:
    bzoj1295 [SCOI2009]最长距离
    bzoj1853 [Scoi2010]幸运数字
    bzoj1855 [Scoi2010]股票交易
    bzoj1294 [SCOI2009]围豆豆
    bzoj1237 [SCOI2008]配对
    bzoj1084 [SCOI2005]最大子矩阵
    bzoj1068 [SCOI2007]压缩
    bzoj1082 [SCOI2005]栅栏
    soj97 旅行
    soj98 卡牌
  • 原文地址:https://www.cnblogs.com/cmxblog/p/11891912.html
Copyright © 2020-2023  润新知