Skip to content

yusaemi/spring-boot-mybatis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spting Boot 搭配 MyBatis

準備作業

此範本需要MySQL資料庫及JDK21環境
支援lombok plugin

Create Table(default schema: master)

可選擇以下兩種方式,擇一使用。

  1. 使用docker-compose.yml建立簡易環境。
  2. 安裝MySQL資料庫,並使用product_schema.sql建立Table

啟動方式

基本執行指令:

  • mvn spring-boot:run

後面可帶參數決定不同環境變數執行,例如

  • mvn spring-boot:run -Ptest

會根據pom.xml<profiles>內容引入相對應變數

測試案例

預設情形之下,在網址打上

https://localhost:8080/product/1

即可看到結果

創建Table的Entity

generatorConfig.xml內部添加table設定,添加的方式在generatorConfig.xml內的註解有說明。
執行maven generator:

  • mvn mybatis-generator:generate

加上-e可查看generator過程:

  • mvn mybatis-generator:generate -e

執行後根據generator.properties配置的參數產生至對應的位置。

About

Spting Boot 搭配 MyBatis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages