type:: note status:: apply star:: 5 relation:: [notion](https://www.notion.so/TODO-TPI-TPIU-Thymeleaf-and-Bootstrap-by-Bootify-b22a0d0b97944f838892a01bc7886611?pvs=4), [gist](https://gist.github.com/wanyutang/8f5d958438b177c26ae7c14cca367d00),[hackmd↗](https://hackmd.io/JM1HwEc-Q9-G7c5179xhlw) - # 使用 Bootify 快速生成 Spring Boot 程式架構 - This article is the original draft, published at [[TPIU 昕力大學]][↗](https://www.tpisoftware.com/tpu/). - ## 簡介 - Bootify 是一個強大且便利的工具,幫助開發者快速生成專案的基礎架構。它支援生成實體類、配置資料庫、UI 以及專案基本設置,對於需要高效構建專案骨架的開發者來說,是一個不可或缺的工具。 - ## 如何使用 Bootify 設置專案 - **Bootify 官網首頁**: ![Bootify 官網首頁](https://gist.github.com/user-attachments/assets/386a9b12-c450-4ac3-af92-07bccbac7b12){:width 300, :height 232} - 進入Bootify 官網首頁選擇 [Start Project] 開始建置專案 - **選擇專案模板**: ![選擇專案模板](https://gist.github.com/user-attachments/assets/3b2172ff-7b97-4a51-8cd2-79948d98d29e){:width 300} - Bootify 提供多種專案模板,方便選擇合適的架構來快速生成基礎項目。 - **設定實體類選項如下**: ![設定實體類](https://gist.github.com/user-attachments/assets/7f250b39-00a3-444a-aad4-725a655436fe){:width 300} - 可自動生成符合需求的實體類,並設置關聯關係及欄位屬性。 - **配置資料庫連線選項如下**: ![實體設置](https://gist.github.com/user-attachments/assets/b36afd5d-338a-43dd-afd0-0e5edf011202){:width 300, :height 140} - 輕鬆完成資料庫配置,支援多種資料庫類型,確保資料存取與操作的穩定性。 - PS. 部份連線模式需要升級成高級會員方能生效。 - ## 使用 Bootify 進行 UI 配置 - **選擇UI模板**: ![選擇UI模板](https://gist.github.com/user-attachments/assets/3a610f39-d236-46d4-abb3-b21a5cd9c72f){:width 300} - Bootify 提供簡單的 UI 配置介面,支援 Thymeleaf 與 Bootstrap 的集成,可以快速生成前端頁面,滿足專案需求。開發者只需通過圖形化界面操作,即可生成完整的 UI 架構,省去手動編寫前端代碼的時間。 - ## 開發環境設置與部署 - **開發模式配置**: ![開發模式參數設置](https://gist.github.com/user-attachments/assets/46c88815-60ee-45f7-a57e-05e70fdb8943){:width 300} - Bootify 支援本地與雲端環境的開發模式設置,並提供各種運行配置選項,方便在不同環境下調整設定。 - **Entities配置**: ![Entities配置](https://gist.github.com/user-attachments/assets/6b9a0176-1fab-4712-901d-36095391cef2){:width 300} - **Schema 建置 Entity **: ![Schema 建置 Entity](https://gist.github.com/user-attachments/assets/d3087474-270f-41df-81ee-d8f53aec733e){:width 300} - [SQL Schema Sample.sql.gist](https://gist.github.com/wanyutang/12af70ac910326412b8806cfa81784e4)[^1] - **Schema 架構圖**: ![Schema 架構圖](https://gist.github.com/user-attachments/assets/3e6e0657-4a38-4bb4-b5c4-67e60314c15f){:width 300} - **Schema Perform import**: ![Schema Perform import](https://gist.github.com/user-attachments/assets/f352ba96-2d81-4769-9ad4-bc619ce6e07e){:width 300} - ## 下載與部署專案 - Bootify 支援 Maven 項目配置,專案生成後可直接下載並在本地 Intellij 中打開,並進行編譯、執行。 - **Download-執行**: ![Download-執行](https://gist.github.com/user-attachments/assets/d225fa36-2e98-4487-8c46-91e22b24c583){:width 300} - **Download-完成**: ![Download-完成](https://gist.github.com/user-attachments/assets/9c9332a8-8b07-445b-93b8-ddbceff760f2){:width 300} - **本機取得建置成果**: ![本機取得建置成果](https://gist.github.com/user-attachments/assets/596fec12-4720-4dfc-a701-6b27a9ed94fb){:width 300} - **Intellij 匯入專案**: ![Intellij 匯入專案](https://gist.github.com/user-attachments/assets/189c7e12-e4d3-4ad2-b0a3-3647dcc201ed){:width 300} - **同意信任專案**: ![同意信任專案](https://gist.github.com/user-attachments/assets/5511ef90-35ef-49f1-8d4e-f7634320294d){:width 300} - **專案結構**: ![專案結構](https://gist.github.com/user-attachments/assets/4a49123c-a8c8-4046-b37d-1c59ef96ccc9){:width 300} - POM.xml - ```xml <?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.3.3</version> <relativePath /><!-- lookup parent from repository --> </parent> <groupId>io.bootify</groupId> <artifactId>my-app</artifactId> <version>0.0.1-SNAPSHOT</version> <name>my-app</name> <properties> <java.version>17</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-validation</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <scope>runtime</scope> </dependency> <dependency> <groupId>io.github.wimdeblauwe</groupId> <artifactId>error-handling-spring-boot-starter</artifactId> <version>4.3.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <dependency> <groupId>nz.net.ultraq.thymeleaf</groupId> <artifactId>thymeleaf-layout-dialect</artifactId> </dependency> <dependency> <groupId>org.webjars</groupId> <artifactId>bootstrap</artifactId> <version>5.3.3</version> </dependency> <dependency> <groupId>org.webjars.npm</groupId> <artifactId>htmx.org</artifactId> <version>2.0.2</version> </dependency> <dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> <version>2.6.0</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-docker-compose</artifactId> <scope>runtime</scope> <optional>true</optional> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <profiles> <profile>local</profile> </profiles> </configuration> </plugin> </plugins> </build> </project> ``` - **部署專案**: ![部署專案](https://gist.github.com/user-attachments/assets/40cb2d6f-ed86-462f-84b3-c52f75ec2578){:width 300} - **部署專案-log**: ![部署專案-log](https://gist.github.com/user-attachments/assets/0ead298e-1d05-471a-9610-6dedc1190024){:width 300} - ## 整合 Swagger - Bootify 內建 Swagger UI 支援,開發者可快速測試 API 接口,查看生成的文件,確認接口是否正確運行。 - **測試結果-首頁**: ![測試結果-首頁](https://gist.github.com/user-attachments/assets/fc116d32-d38d-45ed-beb4-e6a44ce87bd0){:width 300, :height 123} - http://localhost:8080 - **測試結果-Swagger**: ![測試結果-Swagger](https://gist.github.com/user-attachments/assets/ce604ad4-5c9e-4328-b3bc-c3f673e8a20d){:width 300} - http://localhost:8080/swagger-ui/index.html - ## 分享專案架構 - 透過 Bootify,可以輕鬆地將已建置完成的專案分享給他人 - 每個分享的專案會生成一個唯一的連結,可以選擇設置專案為私密或公開 - 在私密模式下,只有收到連結的使用者才能下載並檢視專案 - 這使得與團隊成員或客戶共享專案原始碼與架構更為簡便且安全 - 藉由分享連結,團隊成員可以快速地在自己的開發環境中複製並運行該專案,這大大提升了協作效率,尤其是當需要與多個開發者共同作業時 - ![分享架構](https://gist.github.com/user-attachments/assets/d134cbce-a9e3-4309-858b-d6ce3b272f7f){:width 300} - https://bootify.io/app/WA53UDGLOFK5 - 用 private 訪問可以下載分享的初始模版,包含 Schema (要小心分享權限) - **使用分享連結取得專案**: ![應用檢查](https://gist.github.com/user-attachments/assets/bb6c6c24-16c2-4411-b761-9823e0a26e5f){:width 300} - initial version of product by bootify: https://bootify.io/app/WA53UDGLOFK5 - ## 總結 - Bootify 是一個工具,可快速生成 Spring Boot 專案架構,支援實體類、資料庫、UI 等配置 - 使用 Bootify 設置專案流程包括選擇專案模板、設定實體類與資料庫連線 - 支援 UI 配置,整合 Thymeleaf 與 Bootstrap,快速生成前端頁面 - 提供開發環境與部署設定,並支援 Maven 專案配置與 Intellij 匯入 - 內建 Swagger UI,用於快速測試 API 並查看文 - ## 延伸閱讀 - [[TPI/TPIU/Role Based Access Control (RBAC) 規劃]]: https://hackmd.io/@VxulnppPQHuOEDANOU92EQ/SymfrcyRA/https%3A%2F%2Fhackmd.io%2F%40VxulnppPQHuOEDANOU92EQ%2FSkG3HqyAC - ## 外部連結 - [[Bootify]] 官網: https://bootify.io - [[TPI/TPIU/Role Based Access Control (RBAC) 規劃]] ACL schema by H2.sql: https://gist.github.com/wanyutang/12af70ac910326412b8806cfa81784e4 - [[Winny Post]] 草稿筆記: https://hackmd.io/@VxulnppPQHuOEDANOU92EQ/SymfrcyRA/%2FJM1HwEc-Q9-G7c5179xhlw - ## 註腳 [^1]: SQL Schema 參考 [[TPI/TPIU/Role Based Access Control (RBAC) 規劃]][↗](https://hackmd.io/@VxulnppPQHuOEDANOU92EQ/SymfrcyRA/https%3A%2F%2Fhackmd.io%2F%40VxulnppPQHuOEDANOU92EQ%2FSkG3HqyAC) 案例 ## 轉載清單 - https://www.tpisoftware.com/tpu/articleDetails/3126?isPin=false - https://hackmd.io/@VxulnppPQHuOEDANOU92EQ/SymfrcyRA/%2FJM1HwEc-Q9-G7c5179xhlw