zoukankan      html  css  js  c++  java
  • ssm整合后打印日志查看执行sql语句

    mybatis.xml

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE configuration
            PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
            "http://mybatis.org/dtd/mybatis-3-config.dtd">
    <configuration>
        <settings>
            <!--打印日志可以看执行的sql语句-->
            <setting name="logImpl" value="STDOUT_LOGGING"/>
        </settings>
    </configuration>

    spring.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: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">
    
        <!--第一步,扫描service-->
        <context:component-scan base-package="com.guangming.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的映射文件 在value中可以使用*号通配符-->
            <property name="mapperLocations" value="classpath:com/guangming/dao/*.xml"></property>
            <!--加载mybatis中的配置文件-->
            <property name="configLocation" value="classpath:mybatis.xml"></property>
        </bean>
        <!--第五步,在spring 的工厂中生成dao接口的实现类对象 -->
        <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
            <!--指定要扫描哪个包下面所有的dao接口-->
            <property name="basePackage" value="com.guangming.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>
    
    </beans>
  • 相关阅读:
    SQL第3课:具有约束的查询(第2部分)
    SQL第1课:SELECT查询
    idea快捷键
    Vue基础
    分布式基础
    数据结构-线性表
    常用算法
    数据结构-概述
    Django使用Jinja2模板引擎
    宿主机nginx使用容器php-fpm处理php请求
  • 原文地址:https://www.cnblogs.com/duguangming/p/10969991.html
Copyright © 2011-2022 走看看