Closed solarisy closed 7 years ago
打印出来的sql语句,其中的LIMIT1,5有两次,导致sql报错
select * from t_weike WHERE `published` = ? AND `publish_user_id` = ? AND `deleted` = ? ORDER BY id desc LIMIT 1,5 LIMIT 1,5
<!--mybatis--> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.0</version> </dependency> <!--mybatis 分页插件--> <!--mapper--> <dependency> <groupId>tk.mybatis</groupId> <artifactId>mapper-spring-boot-starter</artifactId> <version>1.1.0</version> </dependency> <!--pagehelper--> <dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.1.0</version> </dependency> <!--mybatis 分页插件 end -->
<!-- mybatis 配置 start --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="mapperLocations" value="classpath:mybatis/*.xml"/> <property name="plugins"> <array> <bean class="com.github.pagehelper.PageInterceptor"> <property name="properties"> <value>reasonable=true</value> </property> </bean> </array> </property> </bean> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.benmei.weike.dao"/> </bean> <!-- mybatis 配置 end/ -->
PageRowBounds pageRowBounds = new PageRowBounds(1, 5); List<Weike> list = weikeDao.searchWeike(weike,pageRowBounds); long total = pageRowBounds.getTotal();
配置错了,如果使用了 starter ,就不要配置 plugins 里面的拦截器了。直接就可以用了。
打印出来的sql语句,其中的LIMIT1,5有两次,导致sql报错
我的环境:
其中pom.xml配置如下:
Spring的applicationContext.xml配置如下:
Java代码如下: