JavaEE Spring MyBatis如何一步一步實(shí)現(xiàn)數(shù)據(jù)庫(kù)查詢功能
配置好一個(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ù)庫(kù)查詢功能的文章就介紹到這了,更多相關(guān)JavaEE Spring MyBatis數(shù)據(jù)庫(kù)查詢內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. JSP之表單提交get和post的區(qū)別詳解及實(shí)例2. 博客日志摘要暨RSS技術(shù)3. SSM框架整合JSP中集成easyui前端ui項(xiàng)目開發(fā)示例詳解4. JSP的Cookie在登錄中的使用5. XML解析錯(cuò)誤:未組織好 的解決辦法6. 使用XSL將XML文檔中的CDATA注釋輸出為HTML文本7. 告別AJAX實(shí)現(xiàn)無(wú)刷新提交表單8. ASP.NET Core實(shí)現(xiàn)中間件的幾種方式9. XMLDOM對(duì)象方法:對(duì)象屬性10. ASP常用日期格式化函數(shù) FormatDate()
