0
点赞
收藏
分享

微信扫一扫

spring + mybatis + eclipse + pagehelper

全栈顾问 2022-07-27 阅读 60


核心jar 和 配置信息网盘地址:

​​https://pan.baidu.com/s/1tNhTNMPZWCVNLgyeAjeiew​​

 

1.引入jar,主要就俩个jar

spring + mybatis + eclipse + pagehelper_sql

2.修改配置文件applicationContext-mybatis.xml:

  

<!-- define the SqlSessionFactory, notice that configLocation is not needed when you use MapperFactoryBean -->  
<bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />

<property name="configLocation" value="classpath:mybatis-config.xml" />
<property name="plugins">
<array>
<bean class="com.github.pagehelper.PageInterceptor">
<property name="properties">
<!-- config params as the following -->
<value>
param1=value1
</value>
</property>
</bean>
</array>
</property> </bean>

3.测试:

默认已经写好了mapper,service ,所以在controller中直接调用

spring + mybatis + eclipse + pagehelper_jar_02

测试结果:原mapper中sql语句自动添加了limit ? ,代表托管分页成功!!

spring + mybatis + eclipse + pagehelper_jar_03

举报

相关推荐

0 条评论