我使用過 Spring Boot Data JPA,一般來說,專案結構看起來像這樣
my-app/
├─ com.company/
│ ├─ model/
│ ├─ controller/
│ ├─ service/
│ ├─ repository/
│ ├─ MyAppMainClass.java
其中每個檔案夾在一般意義上代表其功能。
model/ has entity classes
controller/ has controller classes that have the routes configured for the app
service/ has service classes that have the logic to process a request
repository/ has repository classes that interact with the database and get the response back
現在我有一個非常簡單的專案,我沒有資料庫組件,但我需要做的就是呼叫其他一些 REST API 并回傳回應。
那么我應該遵循相同的結構并洗掉存盤庫檔案夾并將對其他 REST API 的所有呼叫放在服務檔案夾中的類中嗎?
或者是否有任何其他結構通常更適合于此?也許如果我對這一切的理解有一些不一致,請糾正我。謝謝 :)
uj5u.com熱心網友回復:
我會用消費者包替換存盤庫包。并為每個資源創建一個消費者。
my-app/
├─ com.company/
│ ├─ model/
│ ├─ controller/
│ ├─ service/
│ ├─ consumer/
│ ├─ MyAppMainClass.java
uj5u.com熱心網友回復:
只需洗掉存盤庫包,
my-app/
├─ com.company/
│ ├─ model/
│ ├─ controller/
│ ├─ service/
│ ├─ MyAppMainClass.java
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/314179.html
上一篇:屬性值回傳空
