mybatis集成p6spy

第一步导入jar包

第二步导入spy.properties文件(需要放在mybatis.xml同级目录)

mybatis集成p6spy_第1张图片

第三步编写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>

    <typeAliases>
        <typeAlias type="com.java.entity.User" alias="User"></typeAlias>

        <typeAlias type="com.java.entity.Role" alias="Role"></typeAlias>

        <typeAlias type="com.java.entity.One" alias="One"></typeAlias>

        <typeAlias type="com.java.entity.Two" alias="Two"></typeAlias>

        <typeAlias type="com.java.entity.Goods" alias="Goods"></typeAlias>
    </typeAliases>

    <environments default="p6spy">

        <environment id="mysql">
            <transactionManager type="JDBC"></transactionManager>
            <dataSource type="POOLED">
                <property name="driver" value="com.mysql.cj.jdbc.Driver"></property>
                <property name="url" value="jdbc:mysql://127.0.0.1:3306/my_database"></property>
                <property name="username" value="root"></property>
                <property name="password" value="123456"></property>
            </dataSource>
        </environment>

        <environment id="p6spy">
            <transactionManager type="JDBC"></transactionManager>
            <dataSource type="POOLED">
                <property name="driver" value="com.p6spy.engine.spy.P6SpyDriver"></property>
                <property name="url" value="jdbc:p6spy:mysql://localhost:3306/my_database"></property>
                <property name="username" value="root"></property>
                <property name="password" value="wq304587090"></property>
            </dataSource>
        </environment>

    </environments>

    <mappers>
        <mapper resource="com/java/dao/User/UserDao.xml"></mapper>
        <mapper resource="com/java/dao/Role/RoleDao.xml"></mapper>
        <mapper resource="com/java/dao/One/OneDao.xml"></mapper>
        <mapper resource="com/java/dao/Two/TwoDao.xml"></mapper>
        <mapper resource="com/java/dao/Goods/GoodsDao.xml"></mapper>
    </mappers>

</configuration>

你可能感兴趣的:(mybatis)