JavaEE Spring MyBatis如何一步一步實(shí)現(xiàn)數(shù)據(jù)庫查詢功能
配置好一個(gè)SptingBoot項(xiàng)目配置好MyBatis
JavaEE Spring~MyBatis是什么? 它和Hibernate的區(qū)別有哪些?如何配置MyBatis?
SpringBoot配置文件application.properties簡單介紹
確保MyBatis配置正確
手動(dòng)實(shí)現(xiàn)一個(gè)xml文件
上面我是用的是一個(gè)自定義的接口 此時(shí)沒有它對(duì)應(yīng)的xml文件 此時(shí)我們需要
下圖中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)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. asp中response.write("中文")或者js中文亂碼問題2. CSS hack用法案例詳解3. ASP.NET Core實(shí)現(xiàn)中間件的幾種方式4. JSP servlet實(shí)現(xiàn)文件上傳下載和刪除5. 詳解盒子端CSS動(dòng)畫性能提升6. css代碼優(yōu)化的12個(gè)技巧7. 詳解瀏覽器的緩存機(jī)制8. CSS3中Transition屬性詳解以及示例分享9. 怎樣打開XML文件?xml文件如何打開?10. 怎樣才能用js生成xmldom對(duì)象,并且在firefox中也實(shí)現(xiàn)xml數(shù)據(jù)島?
