1、輸入に依存
1,1mysql
1,2mybatis
1,3web
1,4pagehelper
<! -春ブーツ提供了一个插件- > <依存> <groupIdを> com.github.pagehelper </ groupIdを> <たartifactId> pagehelperスプリング・ブート・スターター</たartifactId> <バージョン> 1.2.5 </バージョン> </依存関係>
図2に示すように、コードジェネレータ
2、設定ファイル
春: データソース: URL:JDBC:MySQLの:// localhostの:? 3306 / 1706bはuseUnicode =真&serverTimezone =アジア/上海のに&characterEncoding = UTF-8&allowMultiQueries = trueに設定します。 ユーザ名:ルート パスワード:ルート パッケージパス##声明MyBatisの持続性スキャン MyBatisの: マッパー-locations: CLASSPATH:。com / BW /マッパー/ * xmlの ログ: レベル: com.bw:デバッグ
3、試験
パッケージcom.bw。 輸入はjava.util.List; 輸入javax.annotation.Resource; 輸入org.junit.Test; 輸入org.junit.runner.RunWith; 輸入org.springframework.boot.test.context.SpringBootTest; 輸入org.springframework.test.context.junit4.SpringRunner; 輸入com.bw.mapper.TEmpMapper; 輸入com.bw.pojo.TEmp; 輸入com.bw.pojo.TEmpExample; 輸入com.bw.pojo.TEmpExample.Criteria; 輸入com.github.pagehelper.PageHelper; @RunWith(SpringRunner。クラス) @SpringBootTest 公衆 クラスWeek01ApplicationTests { @Resource プライベートTEmpMapper tEmpMapper。 @Test 公共 ボイドクエリ(){ TEmpExample例 = 新しいTEmpExample()。 基準C = example.createCriteria()。 / * c.andEnameLike( "%" + "アレン" + "%")。* / PageHelper.startPage( 0,3 )。 リスト <TEMP>リスト= tEmpMapper.selectByExample(例) 用(TEMP温度:リスト){ System.out.printlnは(tEmp.toString())。 } } }