SSM中 spring.xml 配置文件

<!--扫描service的impl-->

<context:component-scan base-package="com.aaa.ssm.service.impl"></context:component-scan>

<!--加载jdbc.properties-->

<context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>

<!--创建dbcp数据源连接池-->

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${driver}"></property>
<property name="url" value="${url}"></property>
<property name="username" value="${user}"></property>
<property name="password" value="${password}"></property>
</bean>

<!--创建mybatis的工厂类对象-->

<bean class="org.mybatis.spring.SqlSessionFactoryBean">
<!--指定数据源-->
<property name="dataSource" ref="dataSource"></property>
<!--加载mybatis的映射文件(mapper.xml) 在value中可以使用*号通配符-->
<property name="mapperLocations" value="classpath:com/aaa/ssm/dao/*.xml"></property>
</bean>

<!--在spring工厂中生成dao接口的实现类对象-->

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!--指定要扫描那个包下面所有的dao接口-->
<property name="basePackage" value="com.aaa.ssm.dao"></property>
</bean>

<!--创建spring的事务管理器-->

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>

<!--声明以注解的方式配置声明式事物-->

<tx:annotation-driven transaction-manager="transactionManager"></tx:annotation-driven>
<!--引入shiro的主配置文件-->
<import resource="classpath:spring-shiro.xml"></import>
 
原文地址:https://www.cnblogs.com/LFY001023/p/10966755.html