构建springboot聚合项目

204 阅读1分钟

1. 项目参考

www.bilibili.com/video/BV1EV…

2. 父模块构建

image.png

type选取pom选项

image.png

勾选的三个模块

image.png

image.png

image.png

父模块命名

image.png

3. 构建子模块

image.png

子模块命名

image.png

需要创建的模块

image.png

web模块的创建

image.png

用dependencyManagement来管理各个模块的version

image.png

image.png

image.png

image.png

image.png

启动类的build

<build>
  <plugins>
    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <configuration>
        <mainClass>com.roy.EntranceAPP</mainClass>
      </configuration>
    </plugin>
  </plugins>
</build>

没有启动类

为了支持打包,必须引入build模块

<build>
  <plugins>
    <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      <configuration>
        <skip>true</skip>
      </configuration>
    </plugin>
  </plugins>
</build>

4. 总结

1.  每个子模块的创建都差不多,唯有web模块不同

2.  package = groupId  + artifactId 

3.  父pom和子pom的groupId保持一致, 子pom的groupId其实是可以省略的

4.  子pom中要有父pom的parent

5.  ${project.parent.version}, 统一采用父项目的版本

6.  检查各个pom是否支持打包, 主启动模块需要build启动类

7. 对于聚合项目,一定要对父项目先install,后边的打包才能一帆风顺,然后再逆着顺序打包
   install
8.