
在spring-mybatis.xml文件中:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
<!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <!-- 自动扫描mapping.xml文件 --> <property name="mapperLocations" value="classpath:com/zghm/bhzg/mapping/*Mapper.xml"></property> <property name="plugins"> <array> <bean class="com.github.pagehelper.PageHelper"> <property name="properties"> <value> dialect=oracle reasonable=true pageSizeZero=true </value> </property> </bean> </array> </property> <property name="configLocation" value="classpath:mybatis-config.xml"></property> </bean>
|
主要加入的是:
1
|
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
|
而这一段代码是我使用的pageHelper配置:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
<property name="plugins"> <array> <bean class="com.github.pagehelper.PageHelper"> <property name="properties"> <value> dialect=oracle reasonable=true pageSizeZero=true </value> </property> </bean> </array> </property>
|
然后在mybatis-config.xml文件中加入:
1 2 3 4 5 6 7 8
|
<?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> <settings> <setting name="logImpl" value="LOG4J"/> </settings> </configuration>
|
log4j.properties
1 2 3 4 5 6 7 8
|
# Global logging configuration log4j.rootLogger=ERROR, stdout # MyBatis logging configuration... log4j.logger.org.mybatis.example.BlogMapper=TRACE # Console output... log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
|
近期评论