Spring整合Mybatis的applictionContext配置

<!--配置连接池-->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/mybatis_db?useSSL=false&amp;characterEncoding=utf8"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</bean>
<!--创建SqlSessionFactory SqlSessionFactoryBean-->
<bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="typeAliasesPackage" value="pojo"/>
<property name="mapperLocations" >
<list>
<value>classpath:XYZ/*Mapper.xml</value>
</list>
</property>
</bean>
<!-- 创建Dao对象 MapperScannerConfigure-->
<bean id="Scanner" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactoryBean"/>
<property name="basePackage" value="XYZ.Dao"/>
</bean>
</beans>
上一篇:01-Spring基础学习


下一篇:2022每日一题:Day 13