springMybatis.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:mvc="http://www.springframework.org/schema/mvc"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"

xsi:schemaLocation="
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd

http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd

http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd

http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.3.xsd

http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
">
<!-- 工厂产生mapper-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.lbnl.mapper"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
<!-- 11. mybatis数据源 : 不带连接池 -->
<bean id="dataSource"
class="org.apache.ibatis.datasource.unpooled.UnpooledDataSource">
<property name="driver" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/bls?characterEncoding=utf-8" />
<property name="username" value="root" />
<property name="password" value="123456" />
</bean>


<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<!-- mybatis的基本配置驼峰,日志-->
<property name="configLocation" value="classpath:config/mybatisConfig.xml"/>
</bean>


<!-- 有个参数 叫transaction-manager默认等于dataSourceTransactionManager 这个可以不写,但是得更下面一样-->
<!-- <tx:annotation-driven transaction-manager="dataSourceTransactionManager"/>-->
<!-- 开启事务驱动-->
<!--
<bean id="dataSourceTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
-->
</beans>
posted @ 2022-08-15 13:38  java小寇  阅读(33)  评论(0)    收藏  举报