Spring与Mybatis整合--使用MapperScannerConfigurer批量扫描Mapper接口实现

时间:2025-05-12 07:53:16
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="/schema/beans" xmlns:xsi="http:///2001/XMLSchema-instance" xmlns:context="/schema/context" xmlns:util="/schema/util" xmlns:jee="/schema/jee" xmlns:tx="/schema/tx" xmlns:jpa="/schema/data/jpa" xmlns:mvc="/schema/mvc" xsi:schemaLocation=" /schema/beans /schema/beans/spring-beans-3. /schema/context /schema/context/spring-context-3. /schema/util /schema/util/spring-util-3. /schema/jee /schema/jee/spring-jee-3. /schema/tx /schema/tx/spring-tx-3. /schema/data/jpa /schema/data/jpa/spring-jpa-1. /schema/mvc /schema/mvc/spring-mvc-3."> <bean id="dataSource" class="" destroy-method="close"> <property name="driverClassName" value="" /> <property name="url" value="jdbc:mysql://localhost:3306/test" /> <property name="username" value="root" /> <!-- property池启动时的初始值 --> <property name="password" value="root" /> <!-- 连接name="initialSize" value="${initialSize}"/> --> <property name="initialSize" value="1" /> <!-- 连接池的最大值 --> <property name="maxActive" value="500" /> <!-- 最大空闲值.当经过一个高峰时间后,连接池可以慢慢将已经用不到的连接慢慢释放一部分,一直减少到maxIdle为止 --> <property name="maxIdle" value="2" /> <!-- 最小空闲值.当空闲的连接数少于阀值时,连接池就会预申请去一些连接,以免洪峰来时来不及申请 --> <property name="minIdle" value="1" /> </bean> <bean id="sqlSessionFactory" class=""> <property name="dataSource" ref="dataSource" /> <property name="mapperLocations" value="classpath:org/xsx/entity/" /> </bean> <bean id="empMapper" class=""> <property name="basePackage" value="" /> </bean> </beans>