12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?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 https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
- <!--扫描组件(除控制层)-->
- <context:component-scan base-package="com.cdxw.ssm">
- <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
- </context:component-scan>
- <!--引入jdbc.properties-->
- <context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>
- <!--配置数据源-->
- <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
- <property name="driverClassName" value="${jdbc.driver}"></property>
- <property name="url" value="${jdbc.url}"></property>
- <property name="username" value="${jdbc.username}"></property>
- <property name="password" value="${jdbc.password}"></property>
- </bean>
- <!--配置事务管理器-->
- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource"></property>
- </bean>
- <!--
- 开启事务的注解驱动
- 将使用@Transactional标识的方法或类中所有的方法进行事务管理
- -->
- <tx:annotation-driven transaction-manager="transactionManager"/>
- <!--配置SqlSessionFactoryBean,可以直接在Spring的IOC中获取SqlSessionFactory-->
- <bean class="org.mybatis.spring.SqlSessionFactoryBean">
- <!--设置MyBatis的核心配置文件的路径-->
- <property name="configLocation" value="classpath:mybatis-config.xml"></property>
- <!--设置数据源-->
- <property name="dataSource" ref="dataSource"></property>
- <!--设置类型别名所对应的包-->
- <property name="typeAliasesPackage" value="com.cdxw.ssm.pojo"></property>
- <!--
- 设置映射文件的路径,在设置了MapperScannerConfigurer的情况下
- 只有映射文件的包和mapper接口的包不一致时需要设置;
- 如果没有设置MapperScannerConfigurer,则一定要设置
- -->
- <!-- <property name="mapperLocations" value="classpath:mappers/*.xml"></property>-->
- <!--配置分页插件,可以在mybatis的配置文件中配置-->
- <!-- <property name="plugins">-->
- <!-- <array>-->
- <!-- <bean class="com.github.pagehelper.PageInterceptor"></bean>-->
- <!-- </array>-->
- <!-- </property>-->
- </bean>
- <!--
- 配置mapper接口的扫描,可以将指定包下所有的mapper接口,通过
- SqlSession创建代理实现类对象,并将这些对象交给IOC容器管理
- -->
- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="basePackage" value="com.cdxw.ssm.mapper"></property>
- </bean>
- </beans>
|