Create a multi module project for springboot

Posted by medusa1414 on Sun, 02 Jan 2022 15:34:05 +0100

Use IDEA to create a new project for maven to manage spring boot (because the community version is used, the plug-in of alibaba is downloaded to help create ~)

Pay attention to modifying the packge. If you use the plug-in, the packge under it will not change. It has always been (PIT)

Top level parent project created successfully! The top-level project does not have to worry about specific business logic, but only completes one task: managing sub modules and defining the versions of Maven dependencies. Now delete all files except pom files and configure pom files


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns=""






There are three key tags in the pom file.

< parent > label

In the parent tag, we specify the "parent dependency" of the project as Spring Boot starter parent. In this way, the Spring Boot component version information defined in Spring Boot starter parent will be automatically brought to the sub module. This approach is also common to most Spring Boot projects. It not only reduces the cost of dependency management, but also does not need to worry about the compatibility between components.

< packaging > label

maven has three packaging types: jar, war, and pom. When we specify the packaging type as pom, it means that the current module is a "boss", which only focuses on the top-level strategy, that is, defining dependency versions and integration sub modules, and does not contain specific business implementations.

< dependency Management > tab

The function of this tag is similar to that of the < parent > tag. Both pass down version information. Dependency management is where the boss es define the top-level strategy. We can define the versions of various dependencies here. When the subproject needs to introduce these dependencies, only specify the groupId and artifactId, regardless of which version to write in the version. After completing the writing of geekbang coupling dependency, let's take a look at the writing of coupling template serv dependency.  

Create a child project under the parent project and click file - > New - > module

As for the parent project, remember to modify the package name without the same!

After creation, if the pom file is not blue but orange, you can right-click the pom file and select add as a maven project. The completed project structure is as follows:

Now you need to configure the top-level project pom file and sub project pom file

The top-level project pom file needs to add sub projects


The sub project pom file needs to be labeled with < parent >


Create another sub project, as above. If you want to call the service of the first sub project in the second sub project, you can add dependencies in the < dependencies > tag in the pom file of the second sub project


Simple demo complete!!!!!!!!!

Topics: Java Maven intellij-idea