序言:
此前,我們主要通過XML來書寫SQL和填補(bǔ)對(duì)象映射關(guān)系。在SpringBoot中我們可以通過注解來快速編寫SQL并實(shí)現(xiàn)數(shù)據(jù)訪問。(僅需配置:mybatis.configuration.map-underscore-to-camel-case=true)。為了方便大家,本案例提供較完整的層次邏輯SpringBoot+MyBatis+Annotation。
具體步驟
1. 引入依賴
在pom.xml 引入ORM框架(Mybaits-Starter)和數(shù)據(jù)庫驅(qū)動(dòng)(MySQL-Conn)的依賴。
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <!--繼承信息 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.M4</version> <relativePath/> </parent> <!--依賴管理 --> <dependencies> <dependency> <!--添加Web依賴 --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <!--添加Mybatis依賴 --> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.3.1</version> </dependency> <dependency><!--添加MySQL驅(qū)動(dòng)依賴 --> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <dependency><!--添加Test依賴 --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> </project>
網(wǎng)頁名稱:詳解SpringBoot快速整合MyBatis(去XML化)-創(chuàng)新互聯(lián)
網(wǎng)址分享:http://www.2m8n56k.cn/article38/dhpcsp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、網(wǎng)站策劃、自適應(yīng)網(wǎng)站、網(wǎng)站收錄、標(biāo)簽優(yōu)化、全網(wǎng)營銷推廣
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:[email protected]。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容