成人无码视频,亚洲精品久久久久av无码,午夜精品久久久久久毛片,亚洲 中文字幕 日韩 无码

資訊專欄INFORMATION COLUMN

springboot+mybatis

wuyumin / 3270人閱讀

摘要:整合一創(chuàng)建項(xiàng)目二配置文件公共配置與選擇無關(guān)指的路徑是不修改相關(guān)配置默認(rèn)必須再下否則掃包掃不到使用數(shù)據(jù)源三文件模塊模塊線程池模塊四啟動類加注解五創(chuàng)建啟動測試

springboot整合mybatis

一.創(chuàng)建springboot項(xiàng)目

二.配置文件: application.yml

#公共配置與profiles選擇無關(guān) mapperLocations指的路徑是src/main/resources(不修改相關(guān)配置默認(rèn)必須再resources下,否則掃包掃不到)
mybatis:
  typeAliasesPackage: com.rainbow.quartzdemo
  mapperLocations: classpath:com/rainbow/quartzdemo/mapper/*.xml

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/test?serverTimezone=CTT&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true
    username: root
    password: root
    driver-class-name: com.mysql.jdbc.Driver
    # 使用druid數(shù)據(jù)源
    type: com.alibaba.druid.pool.DruidDataSource

server:
  port: 8083

三.pom文件

 
        
            org.mybatis.spring.boot
            mybatis-spring-boot-starter
            2.0.1
        

        
        
            org.springframework.boot
            spring-boot-starter-web
        

        
        
            mysql
            mysql-connector-java
        

        
        
            org.springframework.boot
            spring-boot-starter-jdbc
        


        
        
            com.alibaba
            druid
            1.1.3
        
        
            org.springframework.boot
            spring-boot-test
            2.1.3.RELEASE
            test
        
        
            junit
            junit
            4.12
            test
        
        
            org.springframework
            spring-test
            5.1.7.RELEASE
            test
        

    

四.啟動類加注解

@MapperScan("com.rainbow.quartzdemo.mapper")

五.創(chuàng)建Controller,啟動測試

package com.rainbow.test.controller;

import com.rainbow.test.mapper.PersonMapper;
import com.rainbow.test.model.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Controller
@RequestMapping("test")
public class TestController {
    @Autowired
    private PersonMapper personMapper;

    @RequestMapping("person")
    public @ResponseBody Person getPerson(Integer id){
        Person person = personMapper.selectByPrimaryKey(id);
        return person;
    }
}

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://m.hztianpu.com/yun/74813.html

相關(guān)文章

  • SpringBoot非官方教程 | 第七篇:SpringBoot開啟聲明式事務(wù)

    摘要:準(zhǔn)備階段以上一篇文章的代碼為例子,即整合,上一篇文章是基于注解來實(shí)現(xiàn)的數(shù)據(jù)訪問層,這篇文章基于的來實(shí)現(xiàn),并開啟聲明式事務(wù)。創(chuàng)建實(shí)體類數(shù)據(jù)訪問層接口層用戶減塊用戶加塊,聲明事務(wù),并設(shè)計(jì)一個(gè)轉(zhuǎn)賬方法,用戶減塊,用戶加塊。 springboot開啟事務(wù)很簡單,只需要一個(gè)注解@Transactional 就可以了。因?yàn)樵趕pringboot中已經(jīng)默認(rèn)對jpa、jdbc、mybatis開啟了事事...

    tyheist 評論0 收藏0
  • 單手?jǐn)]了個(gè)springboot+mybatis+druid

    摘要:配置想想,我們需要哪些數(shù)據(jù)庫要用到,數(shù)據(jù)庫連接池要用到橋接器要用到,因此要倉庫點(diǎn)我去倉庫中找到搜索這些加進(jìn)去。 本文旨在用最通俗的語言講述最枯燥的基本知識 最近身邊的程序員掀起了學(xué)習(xí)springboot的熱潮,說什么學(xué)會了springboot在大街上就可以橫著走、什么有了springboot媽媽再也不擔(dān)心我的編程了、什么BAT都喜歡的框架...聽得作者那個(gè)心癢癢的,于是找了個(gè)時(shí)間,下載...

    adie 評論0 收藏0
  • SpringBoot2.0之五 優(yōu)雅整合SpringBoot2.0+MyBatis+druid+Pa

    摘要:當(dāng)禁用時(shí),所有關(guān)聯(lián)對象都會即時(shí)加載。不同的驅(qū)動在這方便表現(xiàn)不同。參考驅(qū)動文檔或充分測試兩種方法來決定所使用的驅(qū)動。需要適合的驅(qū)動。系統(tǒng)默認(rèn)值是設(shè)置字段和類是否支持駝峰命名的屬性。 ??上篇文章我們介紹了SpringBoot和MyBatis的整合,可以說非常簡單快捷的就搭建了一個(gè)web項(xiàng)目,但是在一個(gè)真正的企業(yè)級項(xiàng)目中,可能我們還需要更多的更加完善的框架才能開始真正的開發(fā),比如連接池、分...

    hatlonely 評論0 收藏0
  • Springboot項(xiàng)目搭建(四)整合MySQL數(shù)據(jù)庫(MyBatis + 分頁配置)

    springboot整合MySQL數(shù)據(jù)庫(MyBatis + 分頁配置) 一、POM文件添加依賴 org.mybatis.spring.boot mybatis-spring-boot-starter 1.3.1 com.github.pagehelper pagehelper 4.1.0 mysql mysql-connec...

    Alex 評論0 收藏0
  • SpringBoot2.0之四 簡單整合MyBatis

    摘要:從最開始的到后來的,到目前的隨著框架的不斷更新?lián)Q代,也為我們廣大的程序猿提供了更多的方便,一起搭建一個(gè)從控制層到持久層的項(xiàng)目可能需要一兩天的時(shí)間,但是采用的方式,我們可能只需要分鐘就能輕松完成一個(gè)項(xiàng)目的搭建,下面我們介紹一下整合的方法一新建 ??從最開始的SSH(Struts+Spring+Hibernate),到后來的SMM(SpringMVC+Spring+MyBatis),到目前...

    Sanchi 評論0 收藏0

發(fā)表評論

0條評論

閱讀需要支付1元查看
<