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. 利用單元測試對PHP代碼進(jìn)行檢查2. python如何實(shí)現(xiàn)word批量轉(zhuǎn)HTML3. python3實(shí)現(xiàn)往mysql中插入datetime類型的數(shù)據(jù)4. Java8內(nèi)存模型PermGen Metaspace實(shí)例解析5. python爬蟲實(shí)戰(zhàn)之制作屬于自己的一個IP代理模塊6. python excel和yaml文件的讀取封裝7. moment轉(zhuǎn)化時間戳出現(xiàn)Invalid Date的問題及解決8. 如何對php程序中的常見漏洞進(jìn)行攻擊9. js獲取今天、昨天、明天的日期函數(shù)代碼10. python實(shí)現(xiàn)PolynomialFeatures多項(xiàng)式的方法

網(wǎng)公網(wǎng)安備