SpringBoot multi-module project creation and problems encountered

Download link :
https://github.com/LM917178900/multi-module.git

New Project

1. New module

1.1 Create a new multi-module project

Delete others, leaving only pom.xml, *.iml,.gitignore

1.2 New submodule alhpa, beta, common, core

Delete others from the submodule, leaving only src, pom, *.iml

1.3 Internal files of submodules

Get rid of the *Application,resources directory inside the submodule;

Organization module

2 The outermost pom: root

2.1 Packaging method

<packaging>pom</packaging>

2.2 modules

 <modules>
     <module>common</module>
     <module>core</module>
     <module>alpha</module>
     <module>beta</module>
 </modules>

2.3 Pom version management

dependencyManagement

2.4 Configure the main class

Note: The main class is moved one level up and placed on the public directory, and all lower-level files can be scanned;
com.lei.min.CoreApplication

2.5 resource scan xml

                <include>**/*.xml</include>

2.6 resource scan application configuration

                <include>**/*.yml</include>
                <include>**/*.properties</include>

3 submodule pom

3.1 Configure the parent class

<parent>
    <groupId>com.lei.min</groupId>
    <artifactId>module</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>

3.2 Configuration dependency

    <dependency>
        <groupId>com.lei.min</groupId>
        <artifactId>common</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>

3.3 Get rid of redundant configuration spring-boot-maven-plugin

Remove this configuration of all pom

4 Problems encountered

4.1 Cannot find submodule components

See 2.4 for the solution

4.2 Cannot read the application configuration file

See 2.6 for the solution

4.3 startup error repackage failed: Unable to find main class

See 1.3, 2.4 for solutions

4.4 The module under maven in the upper right corner is grayed out

setting (IDEA menu)->maven->Ignored Files, uncheck pom;

Download link :
https://github.com/LM917178900/multi-module.git

Guess you like

Origin blog.csdn.net/leinminna/article/details/112949678