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>
  • 相关阅读:
    WebSocket
    Jedis工具类
    电脑突然没有声音了 右下角红叉叉,由于其配置信息(注册表中的)不完整或已损坏,Windows 无法启动这个硬件设备。 (代码19)
    java.lang.IllegalArgumentException: jdbcUrl is required with driverClassName.
    WCF中的数据契约(Continued)
    WCF中的服务契约
    搭建基于MOSS的团队解决方案01——Microsoft Office SharePoint 2007 Server快速入门(Continued)
    Silverlight 的发展之路
    Windows Workflow Foundation实验01——Windows Workflow Foundation快速入门(练习四)
    使用.NET平台工具操作Live Framework
  • 原文地址:https://www.cnblogs.com/duguangming/p/10969991.html
Copyright © 2011-2022 走看看