Comments (4)
我现在自己实现了配置方法,没有使用starter了,还有一种方式是,直接定义一个PageInterceptor Bean就可以了。
@configuration
@order(Ordered.HIGHEST_PRECEDENCE)
@EnableConfigurationProperties(PageHelperProperties.class)
public class PageHelperConfig {
@Autowired
private PageHelperProperties pageHelperProperties;
@Bean
public BeanPostProcessor pageHelperBeanPostProcessor() {
PageInterceptor interceptor = new PageInterceptor();
interceptor.setProperties(pageHelperProperties.getProperties());
return new BeanPostProcessor() {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof SqlSessionFactory) {
SqlSessionFactory sqlSessionFactory = (SqlSessionFactory) bean;
if (!sqlSessionFactory.getConfiguration().getInterceptors().contains(interceptor)) {
sqlSessionFactory.getConfiguration().addInterceptor(interceptor);
}
}
return bean;
}
};
}
}
from pagehelper-spring-boot.
如果配合 通用 Mapper 使用,可以用 tk.mybatis.mapper.autoconfigure.ConfigurationCustomizer
接口,如果没用 Mapper,可以用 org 版本的。
from pagehelper-spring-boot.
使用了通用 Mapper
后,通用 Mapper
中排除掉了 mybatis
官方的 starter
会导致这个情况,@Configuration @ConditionalOnBean({SqlSessionFactory.class}) @EnableConfigurationProperties({PageHelperProperties.class}) @AutoConfigureAfter({MybatisAutoConfiguration.class}) public class PageHelperAutoConfiguration {
这个使用了 mybatis
官方的 MybatisAutoConfiguration
。
from pagehelper-spring-boot.
所以这个最后的解决办法是什么,我看了半天都没看明白
from pagehelper-spring-boot.
Related Issues (20)
- 在项目中使用热部署,starter中的PageHelperAutoConfiguration会重复添加PageInterceptor
- pom依赖冲突
- 会出现rows有数据但是total的数量等于0的情况 HOT 4
- 大数据量时查询效率的问题
- spring boot3 启动有警告
- pageNum超出totalPages,分页总是返回最后一页的数据 HOT 1
- 依赖引不进来 HOT 2
- 1.4.7依赖有问题 HOT 3
- 关于分页时联表查询count会统计全部行数, 而不是左表行数. HOT 3
- GBase分页会自动把库表连接符冒号:替换成点号. HOT 2
- 通过pagehelper实现较个性化的分页需求 HOT 2
- 第三方依赖建议添加<optional>true</optional> HOT 1
- intellij idea警告try-with-resources HOT 1
- springboot使用1.4.7版本后启动报错 HOT 1
- startPage的orderBy存在字段重复排序问题
- setOrderBy(param.getOrderBy())里面的参数驼峰可以自动转换为下划线吗 HOT 2
- 支持mybatis-plus吗 HOT 4
- 今天从pagehelper.version 1.4.7 升级到 pagehelper.version2.1.0 出现的问题 HOT 9
- 大佬,请问什么时候适配spring boot 3.2呢? HOT 6
- 升级到最新版本后出现PageHelperAutoConfiguration Bad return type HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pagehelper-spring-boot.