最近2018中文字幕在日韩欧美国产成人片_国产日韩精品一区二区在线_在线观看成年美女黄网色视频_国产精品一区三区五区_国产精彩刺激乱对白_看黄色黄大色黄片免费_人人超碰自拍cao_国产高清av在线_亚洲精品电影av_日韩美女尤物视频网站

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
使用SpringBoot+MyBatis框架做查詢操作-創(chuàng)新互聯(lián)

一.在你建立的工程下創(chuàng)建 Module 選擇Spring initializr創(chuàng)建。
使用Spring Boot+MyBatis框架做查詢操作

創(chuàng)新互聯(lián)基于分布式IDC數(shù)據(jù)中心構(gòu)建的平臺為眾多戶提供成都服務(wù)器托管 四川大帶寬租用 成都機柜租用 成都服務(wù)器租用。

二.在Type處選擇: Maven Project(項目的構(gòu)建工具)
使用Spring Boot+MyBatis框架做查詢操作

三.創(chuàng)建依賴時勾上web,mybatis,mysql(這個看你個人需要吧,可以自主選擇)
使用Spring Boot+MyBatis框架做查詢操作

使用Spring Boot+MyBatis框架做查詢操作

建立好的項目結(jié)構(gòu)如下:
使用Spring Boot+MyBatis框架做查詢操作

注意:application.properties和application.yml是同一個東西,均為項目的核心配置文件

內(nèi)容如下:

#連接數(shù)據(jù)庫
spring.datasource.url=jdbc:mysql://localhost:3306/smbms
spring.datasource.username=root
spring.datasource.password=1234
spring.datasource.driverClassName=com.mysql.jdbc.Driver
#引入mybatis的配置文件
mybatis:
mybatis.mapper-locations=classpath:mapper/*.xml
mybatis.type-aliases-package=com.example.sprboot.pojo

相應(yīng)的pom.xml文件
  <?xml version="1.0" encoding="UTF-8"?>

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0

com.example
springboot
0.0.1-SNAPSHOT
jar

springboot
Demo project for Spring Boot


    org.springframework.boot
    spring-boot-starter-parent
    2.0.5.RELEASE
     


    UTF-8
    UTF-8
    1.8


    
    
        org.springframework.boot
        spring-boot-starter-web
    
    
    
        org.springframework.boot
        spring-boot-starter-test
        test
    
    
    
        org.mybatis.spring.boot
        mybatis-spring-boot-starter
        1.3.0
    
    
    
        mysql
        mysql-connector-java
    
    
    
        com.alibaba
        fastjson
        1.2.49
    
    
    
        org.springframework.boot
        spring-boot-starter-thymeleaf
    


    
        
            org.springframework.boot
            spring-boot-maven-plugin
        
    

相應(yīng)的接口UserMapper如下:

@Repository
public interface UserMapper {
List getList();
}

service如下:

public interface UserService {
List getList();
}

impl如下:

@Service
public class UserServiceImpl implements UserService {@Resource
br/>@Resource
br/>@Override
getList() {
return userMapper.getList();
}
}

在resources中建一個文件夾mapper里面放mapper.xml文件,代碼如下:




















工號用戶名姓名性別生日電話地址創(chuàng)建時間

此處有一個th標(biāo)簽,需要引入一個
并在pom.xml中引入對應(yīng)的jar包(html中不能使用jstl表達(dá)式)

大家可以擴展一下thymeleaf的知識

控制器代碼如下:

@Controller
public class UserController {@Resource
br/>@Resource
br/>@RequestMapping("/")
List list=userService.getList();
model.addAttribute("users",list);
System.out.println(list);
return "/index.html";
}
}

注:在調(diào)通的時候,可能會報很多的錯,基本上都是注解的使用出錯,希望各位能夠細(xì)心點

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。


當(dāng)前名稱:使用SpringBoot+MyBatis框架做查詢操作-創(chuàng)新互聯(lián)
文章分享:http://fisionsoft.com.cn/article/geojg.html