SpringBoot+Mysql 搭建后端(含model/service/serviceImpl/dao/map生成工具)

1,maven 項目搭建

具體可以百度,不在贅述.

POM 代碼:

<?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">

<modelVersion>4.0.0</modelVersion>

<groupId>xt_001</groupId>

<artifactId>xt_demo</artifactId>

<version>1.0-SNAPSHOT</version>

<parent>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-parent</artifactId>

<version>2.1.6.RELEASE</version>

</parent>

<dependencies>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-web</artifactId>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-jdbc</artifactId>

</dependency>

<dependency>

<groupId>org.mybatis.spring.boot</groupId>

<artifactId>mybatis-spring-boot-starter</artifactId>

<version>2.0.1</version>

</dependency>

<dependency>

<groupId>mysql</groupId>

<artifactId>mysql-connector-java</artifactId>

<version>5.1.47</version>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-thymeleaf</artifactId>

<version>2.1.0.RELEASE</version>

</dependency>

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-devtools</artifactId>

<version>2.0.0.RELEASE</version>

</dependency>

<dependency>

<groupId>com.alibaba</groupId>

<artifactId>fastjson</artifactId>

<version>1.2.41</version>

</dependency>

</dependencies>

<build>

<plugins>

<plugin>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-maven-plugin</artifactId>

</plugin>

</plugins>

<resources>

<!-- IDEA-解決: org.apache.ibatis.binding.BindingException:Invalid bound statement (not found) -->

           <resource>

<directory>src/main/java</directory>

<includes>

<include>**/*.xml</include>

</includes>

</resource>

</resources>

</build>

</project>

2.新建如截圖文件夾

image

application.yml:

spring:

 profiles:

   active: dev

application-dev.yml:

server:

port:8084

spring:

datasource:

username: root

password: mysql

url: jdbc:mysql://localhost:3306/test1?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&serverTimezone=UTC&useSSL=false

driver-class-name: com.mysql.jdbc.Driver

thymeleaf:

cache:false

    prefix: classpath:/templates/

suffix: .html

encoding: UTF-8

servlet:

content-type: text/html

mode: HTML5

mybatis:

#  mapper 文件夾在resources 路徑下時:

  mapper-locations: classpath:mapper/*.xml

#  mapper 文件夾在package  com.xt 路徑下時

#  mapper-locations: classpath:mapper/*Mapper.xml

#  mapper-locations: classpath:com/xt/mapper/*Mapper.xml

  type-aliases-package: com.xt.entity

application-prd.yml:

可以拷貝application-dev.yml

3.AppMain.java 代碼:

package com.xt;

import org.mybatis.spring.annotation.MapperScan;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication

@MapperScan("com.xt.dao")

public class AppMain {

public static void main(String[] args) {

SpringApplication.run(AppMain.class);

}

}

@MapperScan("com.xt.dao") 作用可以百度

4.關(guān)于easy-code plugin 用法(根據(jù)MySQL數(shù)據(jù)庫表,直接生成entity/service/serviceImpl/dao/mapper):

可以參考 https://www.cnblogs.com/chafe/p/9506001.html

也可以百度 idea easycode plugin

方法二:

https://github.com/838934287/mvc-generate-tool 也可以下載該小工具,修改下MySQL URL 即可使用,也很方面,并且template也可以自己修改.

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末啡捶,一起剝皮案震驚了整個濱河市板辽,隨后出現(xiàn)的幾起案子莉炉,更是在濱河造成了極大的恐慌娇哆,老刑警劉巖,帶你破解...
    沈念sama閱讀 222,590評論 6 517
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件拴疤,死亡現(xiàn)場離奇詭異骚揍,居然都是意外死亡字管,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,157評論 3 399
  • 文/潘曉璐 我一進(jìn)店門信不,熙熙樓的掌柜王于貴愁眉苦臉地迎上來嘲叔,“玉大人,你說我怎么就攤上這事抽活×蚋辏” “怎么了?”我有些...
    開封第一講書人閱讀 169,301評論 0 362
  • 文/不壞的土叔 我叫張陵下硕,是天一觀的道長丁逝。 經(jīng)常有香客問我,道長卵牍,這世上最難降的妖魔是什么果港? 我笑而不...
    開封第一講書人閱讀 60,078評論 1 300
  • 正文 為了忘掉前任沦泌,我火速辦了婚禮糊昙,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘谢谦。我一直安慰自己释牺,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 69,082評論 6 398
  • 文/花漫 我一把揭開白布回挽。 她就那樣靜靜地躺著没咙,像睡著了一般。 火紅的嫁衣襯著肌膚如雪千劈。 梳的紋絲不亂的頭發(fā)上祭刚,一...
    開封第一講書人閱讀 52,682評論 1 312
  • 那天,我揣著相機(jī)與錄音,去河邊找鬼涡驮。 笑死暗甥,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的捉捅。 我是一名探鬼主播撤防,決...
    沈念sama閱讀 41,155評論 3 422
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼棒口!你這毒婦竟也來了寄月?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 40,098評論 0 277
  • 序言:老撾萬榮一對情侶失蹤无牵,失蹤者是張志新(化名)和其女友劉穎漾肮,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體合敦,經(jīng)...
    沈念sama閱讀 46,638評論 1 319
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡初橘,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,701評論 3 342
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了充岛。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片保檐。...
    茶點(diǎn)故事閱讀 40,852評論 1 353
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖崔梗,靈堂內(nèi)的尸體忽然破棺而出夜只,到底是詐尸還是另有隱情,我是刑警寧澤蒜魄,帶...
    沈念sama閱讀 36,520評論 5 351
  • 正文 年R本政府宣布扔亥,位于F島的核電站,受9級特大地震影響谈为,放射性物質(zhì)發(fā)生泄漏旅挤。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,181評論 3 335
  • 文/蒙蒙 一伞鲫、第九天 我趴在偏房一處隱蔽的房頂上張望粘茄。 院中可真熱鬧,春花似錦秕脓、人聲如沸柒瓣。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,674評論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽芙贫。三九已至,卻和暖如春傍药,著一層夾襖步出監(jiān)牢的瞬間磺平,已是汗流浹背魂仍。 一陣腳步聲響...
    開封第一講書人閱讀 33,788評論 1 274
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留拣挪,地道東北人蓄诽。 一個月前我還...
    沈念sama閱讀 49,279評論 3 379
  • 正文 我出身青樓,卻偏偏與公主長得像媒吗,于是被迫代替她去往敵國和親仑氛。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,851評論 2 361

推薦閱讀更多精彩內(nèi)容