av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁技術(shù)文章
文章詳情頁

springboot植入pagerHelper的超詳細(xì)教程

瀏覽:4日期:2023-03-28 09:59:18
簡介

前面?zhèn)€已經(jīng)講過mybatis的批量更新操作。批量操作還有時分頁查詢,針對項(xiàng)目的完善性,來講解一下分頁工具的植入pagerHelper和tk.mybatis使用。其實(shí)官網(wǎng)已經(jīng)有具體代碼,代價有空可以多多參考官網(wǎng)操作。鏈接地址MyBatis-Spring-Boot

技術(shù)方案maven jar導(dǎo)入

查看官方說明引入依賴,如下:

<!--mybatis--><dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.1</version></dependency><!--mapper--><dependency> <groupId>tk.mybatis</groupId> <artifactId>mapper-spring-boot-starter</artifactId> <version>1.2.4</version></dependency><!--pagehelper--><dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.2.3</version></dependency>maven plugin配置

引入完jar依賴之后,配置plugin插件,插件時根據(jù)maven來識別的,可以直接拷貝官網(wǎng)的配置即可,如下:

<plugin><groupId>org.mybatis.generator</groupId><artifactId>mybatis-generator-maven-plugin</artifactId><version>1.3.2</version><configuration> <configurationFile>${basedir}/src/main/resources/generator/generatorConfig.xml</configurationFile> <overwrite>true</overwrite> <verbose>true</verbose></configuration><dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.version}</version> </dependency> <dependency> <groupId>tk.mybatis</groupId> <artifactId>mapper-generator</artifactId> <version>1.0.0</version> </dependency></dependencies> </plugin>配置generatorConfig.xml

根據(jù)自己喜歡,可以定制化配置generatorConfig.xml,下面是我個人基本配置,更多配置說明,請查看官方說明MyBatis Generator 詳解

<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE generatorConfiguration PUBLIC '-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN' 'http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd'><generatorConfiguration> <properties resource='generator/application-dev.properties'/> <context targetRuntime='MyBatis3Simple' defaultModelType='flat'> <property name='beginningDelimiter' value='`'/> <property name='endingDelimiter' value='`'/> <plugin type='tk.mybatis.mapper.generator.MapperPlugin'> <property name='mappers' value='com.lgh.common.util.MyMapper'/> </plugin> <jdbcConnection driverClass='${spring.datasource.driver-class-name}' connectionURL='${spring.datasource.url}' userId='${spring.datasource.username}' password='${spring.datasource.password}'> </jdbcConnection> <javaModelGenerator targetPackage='com.lgh.model' targetProject='src/main/java'/> <sqlMapGenerator targetPackage='mapper' targetProject='src/main/resources'/> <javaClientGenerator targetPackage='com.lgh.mapper' targetProject='src/main/java' type='XMLMAPPER'/> <!-- 數(shù)據(jù)庫表 以及實(shí)體類命名 --> <!-- <table schema='CL_DEMO' tableName='tb_user' domainObjectName='User'enableCountByExample='false' enableDeleteByExample='false'enableSelectByExample='false' enableUpdateByExample='false'selectByExampleQueryId='false' /> <table schema='CL_DEMO' tableName='tb_role' domainObjectName='Role'enableCountByExample='false' enableDeleteByExample='false'enableSelectByExample='false' enableUpdateByExample='false'selectByExampleQueryId='false' /> <table schema='CL_DEMO' tableName='tb_menu' domainObjectName='Menu'enableCountByExample='false' enableDeleteByExample='false'enableSelectByExample='false' enableUpdateByExample='false'selectByExampleQueryId='false' /> <table schema='CL_DEMO' tableName='tb_resource' domainObjectName='Resource'enableCountByExample='false' enableDeleteByExample='false'enableSelectByExample='false' enableUpdateByExample='false'selectByExampleQueryId='false' /> <table schema='CL_DEMO' tableName='user_role' domainObjectName='UserRole'enableCountByExample='false' enableDeleteByExample='false'enableSelectByExample='false' enableUpdateByExample='false'selectByExampleQueryId='false' /> <table schema='CL_DEMO' tableName='role_menu' domainObjectName='RoleMenu'enableCountByExample='false' enableDeleteByExample='false'enableSelectByExample='false' enableUpdateByExample='false'selectByExampleQueryId='false' /> <table schema='CL_DEMO' tableName='menu_resource' domainObjectName='MenuResource'enableCountByExample='false' enableDeleteByExample='false'enableSelectByExample='false' enableUpdateByExample='false'selectByExampleQueryId='false' /> <table schema='CL_DEMO' tableName='role_resource' domainObjectName='RoleResource'enableCountByExample='false' enableDeleteByExample='false'enableSelectByExample='false' enableUpdateByExample='false'selectByExampleQueryId='false' /> <table schema='CL_DEMO' tableName='logon' domainObjectName='Logon'enableCountByExample='false' enableDeleteByExample='false'enableSelectByExample='false' enableUpdateByExample='false'selectByExampleQueryId='false' />--> </context></generatorConfiguration>測試樣例

springboot植入pagerHelper的超詳細(xì)教程

點(diǎn)擊mybatis-generator:generate即可生成對象和映射文件,具體如上圖

一般分頁個人喜好建議用jdk8的lambda表達(dá)式,如://對應(yīng)的lambda用法pageInfo = PageHelper.startPage(1, 10).doSelectPageInfo(() -> userMapper.selectGroupBy());,更多請查看官網(wǎng)分頁使用方式

總結(jié)&反思

基本操作對象,我們不要再手動一個一個的寫啦,直接用mybatis插件生成。基本curd不要再自己編寫xml,直接用tk.mysql操作即可。一對多情況,分頁無法實(shí)現(xiàn)謹(jǐn)慎使用

源碼地址

github

到此這篇關(guān)于springboot植入pagerHelper的文章就介紹到這了,更多相關(guān)springboot植入pagerHelper內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Spring
相關(guān)文章:
主站蜘蛛池模板: 久久久久久91香蕉国产 | 91性高湖久久久久久久久_久久99 | 色吧久久 | 成人在线电影在线观看 | 精品一区二区三区在线观看国产 | 在线免费看91| 久久国产欧美一区二区三区精品 | 伊人最新网址 | 日韩在线播放中文字幕 | 国产视频中文字幕 | 精品国产综合 | 亚洲一区二区三区在线播放 | 成人av观看| 在线中文视频 | 亚洲精品乱码久久久久久久久久 | 日本欧美在线 | 在线视频中文字幕 | 国产精品久久久久aaaa | 久久精品小视频 | 男女免费视频网站 | 欧美九九| 91性高湖久久久久久久久_久久99 | 91在线视频 | 国产成人精品久久 | 国产露脸对白88av | 日韩亚洲视频在线 | av网址在线 | 亚洲v日韩v综合v精品v | 国产精品一区二区三区99 | 亚洲小视频在线播放 | 国产在线一区二区三区 | 亚洲天堂成人在线视频 | 中文字幕 欧美 日韩 | 亚洲国产精品视频一区 | 久久国产成人午夜av影院武则天 | 国产91色在线 | 亚洲 | 日本大片在线播放 | 国产精品久久久久久久久久免费看 | 欧美高清hd | 精品一区二区三区在线观看国产 | 久久精品一级 |