JavaEE Spring MyBatis如何一步一步實現(xiàn)數(shù)據(jù)庫查詢功能
配置好一個SptingBoot項目配置好MyBatis
JavaEE Spring~MyBatis是什么? 它和Hibernate的區(qū)別有哪些?如何配置MyBatis?
SpringBoot配置文件application.properties簡單介紹
確保MyBatis配置正確
手動實現(xiàn)一個xml文件
上面我是用的是一個自定義的接口 此時沒有它對應(yīng)的xml文件 此時我們需要
下圖中column表示查詢列, property表示返回類型中的屬性
在Controller中進行測試
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如何一步一步實現(xiàn)數(shù)據(jù)庫查詢功能的文章就介紹到這了,更多相關(guān)JavaEE Spring MyBatis數(shù)據(jù)庫查詢內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. ASP 信息提示函數(shù)并作返回或者轉(zhuǎn)向2. CentOS郵件服務(wù)器搭建系列—— POP / IMAP 服務(wù)器的構(gòu)建( Dovecot )3. css代碼優(yōu)化的12個技巧4. .NET SkiaSharp 生成二維碼驗證碼及指定區(qū)域截取方法實現(xiàn)5. MyBatis JdbcType 與Oracle、MySql數(shù)據(jù)類型對應(yīng)關(guān)系說明6. idea自定義快捷鍵的方法步驟7. ASP中if語句、select 、while循環(huán)的使用方法8. IntelliJ IDEA設(shè)置背景圖片的方法步驟9. django創(chuàng)建css文件夾的具體方法10. jsp網(wǎng)頁實現(xiàn)貪吃蛇小游戲
