本文介紹如何基于盤古開發(fā)框架開發(fā)一個單體分層架構(gòu)的應(yīng)用。文中所述僅為搭建一個單體應(yīng)用的基本框架牢硅,增加配置中心蹬耘、數(shù)據(jù)持久化、緩存等能力請參考開發(fā)指南的相關(guān)章節(jié)减余。
背景
軟件架構(gòu)的本質(zhì)是一種在特定資源背景下折中平衡后追求業(yè)務(wù)增長的一門藝術(shù)综苔。雖然盤古框架的標(biāo)準(zhǔn)姿勢是分布式微服務(wù)開發(fā),但決定技術(shù)開發(fā)架構(gòu)選型的因素很多位岔,單體應(yīng)用依舊有很多應(yīng)用場景如筛。因此,盤古框架不會綁定用戶到一個固定的開發(fā)范式和架構(gòu)上赃承,而是支持隨意組合妙黍、自動裝配、靈活插拔瞧剖。 既能構(gòu)建大并發(fā)高可用的分布式微服務(wù)架構(gòu)也能搭建小巧的垂直單體分層架構(gòu)。
安裝相關(guān)盤古模塊
<!-- 盤古 Parent -->
<parent>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-parent</artifactId>
<version>latest.version.xxx</version>
<relativePath/>
</parent>
<!-- 基礎(chǔ)模塊 -->
<dependency>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-spring-boot-starter</artifactId>
</dependency>
<!-- Web模塊 -->
<dependency>
<groupId>com.gitee.pulanos.pangu</groupId>
<artifactId>pangu-web-spring-boot-starter</artifactId>
</dependency>
本地配置
為便于理解,本文基于本地配置的方式編寫抓于。若改為標(biāo)準(zhǔn)的 Nacos 配置中心模式做粤,請參閱:配置中心 章節(jié)。
spring.application.name=pangu-examples-empty-web
spring.jackson.time-zone=GMT+8
logging.level.root=INFO
logging.level.com.gitee.pulanos.pangu=INFO
啟動入口
@SpringBootApplication
public class EmptyWebPanguApplication {
public static void main(String[] args) {
PanGuApplicationBuilder.init(EmptyWebPanguApplication.class).run(args);
}
}
本文相關(guān)范例源碼
- pangu-examples-empty-web:單體分層Web應(yīng)用范例
下一步
繼續(xù)閱讀其它章節(jié)獲取你想要的答案或通過我們的 開發(fā)者社區(qū) 尋求更多幫助捉撮。
參考文獻
盤古開發(fā)框架形象大使.gif