chrisptang / cat-client-mybatis

MyBatis接入大众点评CAT监控平台

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MyBatis进行拦截,并加入到CAT监控。

源码源自CAT框架埋点方案集成/mybatis。源码改动内容有如下:

  • 构建成Maven项目
  • 重写getSqlURL方法
  • 修复SQL的URLjdbc:mysql://unknown:3306/%s?useUnicode=true的问题
  • 扩展支持常见的数据源druiddbcpdbcp2c3p0HikariCPBoneCP

安装到本地仓库命令:

mvn clean install

客户端依赖声明方式:

<dependency>
    <groupId>com.dianping.cat</groupId>
    <artifactId>cat-client-mybatis</artifactId>
    <version>2.0.0</version>
</dependency>

或者使用我托管的仓库fanlychie-maven-repo直接声明依赖:

<repositories>
    <repository>
        <id>fanlychie-maven-repo</id>
        <url>https://raw.github.com/fanlychie/maven-repo/releases</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>com.dianping.cat</groupId>
        <artifactId>cat-client-mybatis</artifactId>
        <version>2.0.0</version>
    </dependency>
</dependencies>

接入方式:

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="typeAliasesPackage" value="org.fanlychie.entity"/>
    <property name="configLocation" value="classpath:mybatis-config.xml"/>
    <property name="mapperLocations" value="classpath*:mapper/*.xml"/>
    <!-- MyBatis 接入 CAT -->
    <property name="plugins">
        <array>
            <bean class="com.wanda.cat.sample.plugins.CatMybatisPlugin"></bean>
        </array>
    </property>
</bean>

效果图:

image

About

MyBatis接入大众点评CAT监控平台


Languages

Language:Java 100.0%