JavaEE Spring MyBatis如何一步一步實(shí)現(xiàn)數(shù)據(jù)庫查詢功能
配置好一個SptingBoot項(xiàng)目配置好MyBatis
JavaEE Spring~MyBatis是什么? 它和Hibernate的區(qū)別有哪些?如何配置MyBatis?
SpringBoot配置文件application.properties簡單介紹
確保MyBatis配置正確
手動實(shí)現(xiàn)一個xml文件
上面我是用的是一個自定義的接口 此時沒有它對應(yīng)的xml文件 此時我們需要
下圖中column表示查詢列, property表示返回類型中的屬性
在Controller中進(jìn)行測試
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)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. ASP 連接Access數(shù)據(jù)庫的登陸系統(tǒng)2. phpstudy apache開啟ssi使用詳解3. 深入理解Android熱修復(fù)技術(shù)原理之代碼熱修復(fù)技術(shù)4. asp知識整理筆記4(問答模式)5. ASP腳本組件實(shí)現(xiàn)服務(wù)器重啟6. Java雙向鏈表按照順序添加節(jié)點(diǎn)的方法實(shí)例7. Android實(shí)現(xiàn)簡單用戶注冊案例8. Python實(shí)現(xiàn)播放和錄制聲音的功能9. python 爬取豆瓣網(wǎng)頁的示例10. AJAX的跨域問題解決方案
