前段時間自己整理了一份關於SpringBoot的項目文章,文中對SpringBoot的常用技術整合通過代碼做了一個比較具體的入門展示,很高興在自己學習的同時,能夠幫助到大家.鑒於一些朋友想要源碼,於是自己將文章中的代碼實現進一步優化,提取成一個方便進行二次開發的腳手架項目,並輔以非常詳細的說明注釋,放在gitee上供大家直接學習使用,然后刪除了此篇文章的代碼示例,僅保留說明部分.
Gitee項目地址 ApiStarter ,大家先閱讀readme.md說明,可以快速了解整個項目,也希望大家能夠提出自己的意見或建議.
本項目是一個Spring boot項目.先看一下官方對Spring Boot的定義
Our primary goals are:
- Provide a radically faster and widely accessible getting started experience for all Spring development.
- Be opinionated out of the box, but get out of the way quickly as requirements start to diverge from the defaults.
- Provide a range of non-functional features that are common to large classes of projects (e.g. embedded servers, security, metrics, health checks, externalized configuration).
- Absolutely no code generation and no requirement for XML configuration.
開箱即用,目標就是簡化簡化再簡化開發,嗯,那我們的目標也是咯.
一、nginx/zuul做LB eureka高可用做注冊中心
二、前后分離通過JSON交互數據
三、Controller層使用適配器
四、Service層很常規
五、JWT做token驗證
六、AOP做請求記錄
七、mybatis generator自動生成mapper、model、xml
八、Logback做日志記錄
九、自定義javadoc doclet做接口描述文檔
十、連接池使用dbcp2
十一、redis緩存
十二、WebMvcConfigurerAdapter攔截器
十三、LineRunner啟動任務加載基礎數據
十四、ApplicationListener監聽器
十五、數據庫使用mysql
十六、線程池用來執行task定時任務
十七、統一異常處理
看一下項目結構,讓我們有一個整體的了解: