JavaEE Spring MyBatis如何一步一步實(shí)現(xiàn)數(shù)據(jù)庫查詢功能
配置好一個(gè)SptingBoot項(xiàng)目配置好MyBatis
JavaEE Spring~MyBatis是什么? 它和Hibernate的區(qū)別有哪些?如何配置MyBatis?
SpringBoot配置文件application.properties簡(jiǎn)單介紹
確保MyBatis配置正確
手動(dòng)實(shí)現(xiàn)一個(gè)xml文件
上面我是用的是一個(gè)自定義的接口 此時(shí)沒有它對(duì)應(yīng)的xml文件 此時(shí)我們需要
下圖中column表示查詢列, property表示返回類型中的屬性
在Controller中進(jìn)行測(cè)試
package listen.controller;import listen.mapper.TestMapper;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;/** * Created with IntelliJ IDEA. * Description: If you don’t work hard, you will a loser. * User: Listen-Y. * Date: 2020-08-21 * Time: 23:14 */@RestController@RequestMapping(value = 'user')public class MyselfTest { @Autowired private TestMapper testMapper; @RequestMapping(value = 'test') public Object test() { return testMapper.query(1); }}
總結(jié)
到此這篇關(guān)于JavaEE Spring MyBatis如何一步一步實(shí)現(xiàn)數(shù)據(jù)庫查詢功能的文章就介紹到這了,更多相關(guān)JavaEE Spring MyBatis數(shù)據(jù)庫查詢內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. python GUI庫圖形界面開發(fā)之PyQt5動(dòng)態(tài)(可拖動(dòng)控件大小)布局控件QSplitter詳細(xì)使用方法與實(shí)例2. ASP動(dòng)態(tài)include文件3. 概述IE和SQL2k開發(fā)一個(gè)XML聊天程序4. ASP將數(shù)字轉(zhuǎn)中文數(shù)字(大寫金額)的函數(shù)5. js開發(fā)中的頁面、屏幕、瀏覽器的位置原理(高度寬度)說明講解(附圖)6. CSS清除浮動(dòng)方法匯總7. 不要在HTML中濫用div8. vue跳轉(zhuǎn)頁面常用的幾種方法匯總9. CSS3實(shí)例分享之多重背景的實(shí)現(xiàn)(Multiple backgrounds)10. XML入門的常見問題(三)
