<?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 u65e5u5fd7u5728u63a7u5236u8f93u51fau914du7f6e ###################################################################################### 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 u6bcfu5929u4ea7u751fu4e00u4e2au65e5u5fd7u6587u4ef6uff0cu6587u4ef6u540du683cu5f0f: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