src/main/resources/spring/spring-mybatis.xml

(完整代码) 2KB

<?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
       http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">

    <!-- 配置数据源 -->
    <context:property-placeholder location="classpath:jdbc.properties" />
    <context:component-scan base-package="com.byh.biyesheji.service" />

    <bean id="druidDataSource" class="com.alibaba.druid.pool.DruidDataSource">
        <property name="url" value="${jdbc.jdbcUrl}" />
        <property name="username" value="${jdbc.user}" />
        <property name="password" value="${jdbc.password}" />
    </bean>

    <!-- 配置 SqlSessionFactory -->
    <bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
        <!-- 配置mapper全局配置文件的位置 -->
        <property name="configLocation" value="classpath:mybatis/mybatis.xml" />
        <!-- 指定数据源 -->
        <property name="dataSource" ref="druidDataSource" />
        <!-- 指定mapper配置文件 -->
        <property name="mapperLocations" value="classpath:mapper/*.xml" />
        <!-- 配置mybatis分页插件PageHelper -->
        <property name="plugins">
            <array>
                <bean class="com.github.pagehelper.PageInterceptor">
                    <property name="properties">
                        <!-- 什么都不配,使用默认的配置 -->
                        <value></value>
                    </property>
                </bean>
            </array>
        </property>

    </bean>

    <!-- 配置扫描器,扫描所有的mapper接口 -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.byh.biyesheji.dao"/>
    </bean>

    <!--事务管理-->
    <tx:annotation-driven transaction-manager="transactionManager"/>
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="druidDataSource" />
    </bean>

</beans>

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。