ssm configuration of 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">
 <! - Configure the scan package ->
    <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>
    
    <! - Load properties Profile ->
    <context:property-placeholder location="classpath:jdbc.properties"/>
    <! - Configure Data Source ->
    <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>
    
    
    <! - Configure Data Source Transaction Manager ->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
      <property name="dataSource" ref="dataSource"></property>
    </bean>
    
    <-! Spring Integration MyBatis two steps ->
     <! - Load mybatis global configuration file, generate sqlSessionFactory Object ->
    <bean class="org.mybatis.spring.SqlSessionFactoryBean">
      <property name="dataSource" ref="dataSource"></property>
      <property name="configLocation" value="classpath:mybatis-config.xml"></property>
    </bean>
    
    <-! Mapper Interface Configuration ->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
      <property name="basePackage" value="com.offcn.dao"></property>
    </bean>
    
    
    <! - open annotation-based transaction support ->
    <tx:annotation-driven transaction-manager="transactionManager"/>

</beans>

 

 

Guess you like

Origin www.cnblogs.com/cmxblog/p/11891912.html