mybatis - mapper配置文件的头部--mybatis-config.xml--log4j 文件--db.properties

目录

    • 1)mapper配置文件的头部
    • 2) mybatis-config.xml
    • 3)log4j.xml
    • 4)db.properties

1)mapper配置文件的头部




<mapper namespace="com.htb.mapper.XXXMapper">

mapper>

2) mybatis-config.xml




<configuration>
    <properties resource="db.properties">properties>
    
    <settings>
    <setting name="cacheEnabled" value="true"/>
    settings>


    <typeAliases>
        <package name="com.xxx.entity"/>
    typeAliases>
    
    <environments default="development">
        <environment id="development">
            <transactionManager type="JDBC"/>
            <dataSource type="POOLED">
                <property name="driver" value="${jdbc.driver}"/>
                <property name="url" value="${jdbc.url}"/>
                <property name="username" value="${jdbc.user}"/>
                <property name="password" value="${jdbc.pass}"/>
            dataSource>
        environment>
    environments>

    <mappers>
        <mapper resource="static/XXXMapper.xml"/>
        

        <mapper class="com.htb.mapper.PersonMapperAPI">mapper>
        
    mappers>
configuration>

3)log4j.xml




<log4j:configuration debug="true">

    <appender name="log.console" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss,SSS} %5p (%C{1}:%M) - %m%n" />
        layout>
    appender>
    
    <logger name="org.apache.ibatis">
        <level value="info" />
        <appender-ref ref="log.console" />
    logger>
  
    <logger name="com.xxx">
        <level value="debug" />
        <appender-ref ref="log.console" />
    logger>

log4j:configuration>

4)db.properties

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3307/kh83
jdbc.user=xxxx
jdbc.pass=xxxx

你可能感兴趣的:(轮子,mybatis,log4j)