1. 程式人生 > >spring boot多模組配置

spring boot多模組配置

目標,建立多模組的spring boot專案。包含三個模組producer consumer model

其中 producer和consumer依賴於model

File->new Project 新建maven 工程作為父模組

next

工程建立完成後把src資料夾刪除

右鍵點選工程資料夾demo

建立spring boot子模組 

consumer模組建立完畢後,修改consumer模組pom.xml中的parent

producer模組和model模組的建立同上

修改父模組demo的pom.xml,新增parent和model

由於producer和consumer依賴model,所以在producer和consumer的pom中加入model的依賴

這樣多模組就配置好了。

需要注意的是,對model的使用只能通過import,而不能使用@Autowired自動注入