MyBatis配置文件mybatis-config.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"> <!--通过这个配置文件,完成mybatis与数据库的连接 --> <configuration> <!-- 注意此配置文件内的元素的 --> <!-- 引入database.properties文件 --> <properties resource="database.properties"/> <!--配置mybatis的log实现为LOG4J --> <!-- 配置后,后台就会有sql语句的输出 --> <settings> <setting name="logImpl" value="LOG4J"/> </settings> <!-- 设置类的别名 --> <typeAliases> <!-- <typeAlias alias="User" type="com.wu.pojo.User"/> --> <!-- 根据包取别名,把包下面的所有类都按类名来取别名 --> <!-- 这用可以简化代码量 --> <package name="com.wu.pojo"/> </typeAliases>


<environments default="development"> <environment id="development"> <!-- 配置事务管理 ,采用JDBC管理事务--> <transactionManager type="JDBC"/> <!-- POOLED是mybatis的 数据源 --> <!-- JNDI是基于tomcat的数据源 --> <dataSource type="POOLED"> <property name="driver" value="${driver}"/> <property name="url" value="${url}"/> <property name="username" value="${username}"/> <property name="password" value="${password}"/> </dataSource> </environment> </environments> <!-- pojo的映射文件UserMapper引入到配入到配置文件中 --> <mappers> <!-- resource要写成路径 --> <mapper resource="com/wu/dao/UserMapper.xml"/> <mapper resource="com/wu/dao/RoleMapper.xml"/> <package name=""/><!-- ???用处??? --> </mappers> </configuration>

 

log4j.properties配合文件

log4j.rootLogger=DEBUG,CONSOLE,file
#log4j.rootLogger=ERROR,ROLLING_FILE
log4j.logger.com.wu.dao=debug
log4j.logger.com.ibatis=debug 
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug 
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug 
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug 
log4j.logger.java.sql.Connection=debug 
log4j.logger.java.sql.Statement=debug 
log4j.logger.java.sql.PreparedStatement=debug 
log4j.logger.java.sql.ResultSet=debug 
log4j.logger.org.tuckey.web.filters.urlrewrite.UrlRewriteFilter=debug

######################################################################################
# Console Appender  \u65e5\u5fd7\u5728\u63a7\u5236\u8f93\u51fa\u914d\u7f6e
######################################################################################
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.Threshold=error
log4j.appender.CONSOLE.Target=System.out
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern= [%p] %d %c - %m%n


######################################################################################
# DailyRolling File  \u6bcf\u5929\u4ea7\u751f\u4e00\u4e2a\u65e5\u5fd7\u6587\u4ef6\uff0c\u6587\u4ef6\u540d\u683c\u5f0f:log2009-09-11
######################################################################################
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.file.DatePattern=yyyy-MM-dd
log4j.appender.file.File=log.log
log4j.appender.file.Append=true
log4j.appender.file.Threshold=error
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-M-d HH:mm:ss}%x[%5p](%F:%L) %m%n


log4j.logger.com.opensymphony.xwork2=error  

 

    原文作者:MyBatis
    原文地址: https://www.cnblogs.com/fifiyong/p/6387690.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞