2

I'm migrating from Spring Boot 2.0.4 to 2.7.0 and facing the following problem:

Project structure
Multi-module project:

/parent-project
  +core
  +monitoring
  +simulator

Project "monitoring" depends on "core".
Project "simulator" depends on both "monitoring" and "core".

Maven POM file

src/pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>my.company.parent_project</groupId>
    <artifactId>parent_project</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.0</version>
    </parent>

    <properties>
        <java.version>1.8</java.version>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <repositories>
        <repository>
           <id>central</id>
           <url>https://repo1.maven.org/maven2/</url>
        </repository>
    </repositories>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-jpa -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>


    </dependencies>

    <modules>
        <module>core</module>
        <module>monitoring</module>
        <module>simulator</module>
    </modules>
</project>

src/core/pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <artifactId>core</artifactId>
    <packaging>jar</packaging>

    <parent>
        <groupId>my.company.parent_project</groupId>
        <artifactId>parent_project</artifactId>
        <version>1.0.0</version>
    </parent>
</project>

src/monitoring/pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <artifactId>monitoring</artifactId>
    <packaging>jar</packaging>

        <parent>
        <groupId>my.company.parent_project</groupId>
        <artifactId>parent_project</artifactId>
        <version>1.0.0</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>my.company.parent_project</groupId>
            <artifactId>core</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>

    <build>
        <finalName>monitoring</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                        <configuration>
                            <classifier>flat</classifier>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            
        </plugins>
    </build>

</project>

src/simulator/pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <artifactId>simulator</artifactId>
    <packaging>jar</packaging>

    <parent>
        <groupId>my.company.parent_project</groupId>
        <artifactId>parent_project</artifactId>
        <version>1.0.0</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>my.company.parent_project</groupId>
            <artifactId>core</artifactId>
            <version>1.0.0</version>
        </dependency>
        
        <dependency>
            <groupId>my.company.parent_project</groupId>
            <artifactId>monitoring</artifactId>
            <version>1.0.0</version>
        </dependency>
            
    </dependencies>

    <build>
        <finalName>simulator</finalName>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                        <configuration>
                            <classifier>flat</classifier>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

Problem

In Spring Boot 2.0.4, when I compile the project "monitoring", it will build 2 jar files as below:

enter image description here

The file "monitoring-flat.jar" is full-packed and used for standalone execution via java -jar command.
The file "monitoring.jar" is not full-packed, which is used for compiling the dependence project "simulator". This works fine in Spring Boot 2.0.4.

However, when I migrated to Spring Boot 2.7.0, it will not work anymore. The output will be as follow:

enter image description here

Both file "monitoring-flat.jar" and "monitoring.jar" is full-packed. In addition, I see that the file "monitoring.jar.original" is not full-packed.

When compiling the project "simulator", an error will happen because it cannot access the compiled class from the file "monitoring.jar".

mvn -f pom.xml  -Dmaven.test.skip=true package -B -e -U 

 --------------< parent_project:monitoring >---------------
[INFO] Building monitoring 1.0.0                                          
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ monitoring ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 0 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ monitoring ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:3.2.0:testResources (default-testResources) @ monitoring ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ monitoring ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ monitoring ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.2.2:jar (default-jar) @ monitoring ---
[INFO] 
[INFO] --- spring-boot-maven-plugin:2.7.0:repackage (repackage) @ monitoring ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- spring-boot-maven-plugin:2.7.0:repackage (default) @ monitoring ---
[INFO] Attaching repackaged archive ...\src\monitoring\target\monitoring-flat.jar with classifier flat
[INFO]

[INFO] -------------< parent_project:simulator >-------------
[INFO] Building simulator 1.0.0                                       [6/7]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:3.2.0:resources (default-resources) @ simulator ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Using 'UTF-8' encoding to copy filtered properties files.
[INFO] Copying 0 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ simulator ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 16 source files to [project path]\src\simulator\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[26,64] package [my package].monitoring.service.customer does not exist
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[27,79] package [my package].monitoring.service.customer.device.message does not exist
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[28,79] package [my package].monitoring.service.customer.device.message does not exist
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[29,79] package [my package].monitoring.service.customer.device.message does not exist

[INFO] 82 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for device-manager 1.0.0:
[INFO]
[INFO] [parent_project] ..................................... SUCCESS [  0.018 s]
[INFO] core ............................................... SUCCESS [ 19.815 s]
[INFO] monitoring ......................................... SUCCESS [  9.860 s]
[INFO] simulator ...................................... FAILURE [  9.909 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:27 min
[INFO] Finished at: 2022-06-02T14:31:24+07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project simulator: Compilation failure: Compilation failure: 
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[26,64] package [my package].monitoring.service.customer does not exist
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[27,79] package [my package].monitoring.service.customer.device.message does not exist

[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[63,17] cannot find symbol
[ERROR]   symbol:   variable super
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[66,9] method does not overri
de or implement a method from a supertype
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[70,17] cannot find symbol   
[ERROR]   symbol:   variable super
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[73,9] method does not overri
de or implement a method from a supertype
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[79,22] cannot find symbol   
[ERROR]   symbol:   variable WebsocketMessage
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[87,22] cannot find symbol   
[ERROR]   symbol:   variable WebsocketMessage
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[93,41] cannot find symbol   
[ERROR]   symbol:   variable logger
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[98,33] cannot find symbol   
[ERROR]   symbol:   variable logger
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[103,25] cannot find symbol

[ERROR]   symbol:   method getChannel()
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[207,25] cannot find symbol  
[ERROR]   symbol:   variable logger
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[239,25] cannot find symbol  
[ERROR]   symbol:   class DeviceMessage
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[239,53] cannot find symbol  
[ERROR]   symbol:   class DeviceMessage
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[241,40] cannot find symbol
[ERROR]   symbol:   variable DeviceMessageType
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[244,53] cannot find symbol  
[ERROR]   symbol:   variable DeviceMessageResult
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[247,60] cannot find symbol  
[ERROR]   symbol:   variable ResponseDeviceStatus
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[251,60] cannot find symbol  
[ERROR]   symbol:   variable ResponseDeviceStatus
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[254,60] cannot find symbol
[ERROR]   symbol:   variable ResponseDeviceStatus
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[257,60] cannot find symbol
[ERROR]   symbol:   variable ResponseDeviceStatus
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[260,60] cannot find symbol
[ERROR]   symbol:   variable ResponseDeviceStatus
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[263,60] cannot find symbol
[ERROR]   symbol:   variable ResponseDeviceStatus
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[266,60] cannot find symbol
[ERROR]   symbol:   variable ResponseDeviceStatus
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[278,38] cannot find symbol
[ERROR]   symbol:   class WebsocketMessage
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[278,55] cannot find symbol  
[ERROR]   symbol:   variable WebsocketMessage
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[279,41] cannot find symbol
[ERROR]   symbol:   method getChannel()
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[285,25] cannot find symbol  
[ERROR]   symbol:   variable logger
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[302,25] cannot find symbol  
[ERROR]   symbol:   class DeviceMessage
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[302,53] cannot find symbol  
[ERROR]   symbol:   class DeviceMessage
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[304,40] cannot find symbol  
[ERROR]   symbol:   variable DeviceMessageType
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[308,53] cannot find symbol  
[ERROR]   symbol:   variable DeviceMessageResult
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[315,38] cannot find symbol  
[ERROR]   symbol:   class WebsocketMessage
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[315,55] cannot find symbol  
[ERROR]   symbol:   variable WebsocketMessage
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[316,41] cannot find symbol
[ERROR]   symbol:   method getChannel()
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/SimulatorWebsocketManager.java:[322,25] cannot find symbol
[ERROR]   symbol:   variable logger
[ERROR]   location: class parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/Simulator.java:[144,22] cannot find symbol
[ERROR]   symbol:   variable THROUGH
[ERROR]   location: class parent_project.simulator.api.Simulator
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/Simulator.java:[147,22] cannot find symbol
[ERROR]   symbol:   variable FAULTED
[ERROR]   location: class parent_project.simulator.api.Simulator
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/Simulator.java:[150,22] cannot find symbol
[ERROR]   symbol:   variable INITIALIZING
[ERROR]   location: class parent_project.simulator.api.Simulator
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/Simulator.java:[153,22] cannot find symbol
[ERROR]   symbol:   variable UPDATING
[ERROR]   location: class parent_project.simulator.api.Simulator
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/Simulator.java:[156,22] cannot find symbol
[ERROR]   symbol:   variable REBOOTING
[ERROR]   location: class parent_project.simulator.api.Simulator
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/Simulator.java:[200,40] cannot find symbol
[ERROR]   symbol:   method run()
[ERROR]   location: variable manager of type parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/api/Simulator.java:[220,32] cannot find symbol
[ERROR]   symbol:   method stop()
[ERROR]   location: variable manager of type parent_project.simulator.api.SimulatorWebsocketManager
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/gui/MainGUI.java:[1412,41] cannot find symbol
[ERROR]   symbol: class ResponseDeviceStatus
[ERROR] [project path]/src/simulator/src/main/[my package]/simulator/gui/MainGUI.java:[1412,71] cannot find symbol
[ERROR]   symbol: variable ResponseDeviceStatus
[ERROR] -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project simulator: Compilat
ion failure
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
    at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:1310)
    at org.apache.maven.plugin.compiler.CompilerMojo.execute (CompilerMojo.java:198)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :simulator

Could anyone know how to fix the issue?

Environment information:

  • Issue happen on both Apache Maven 3.6.3/3.8.4
  • Java JDK 1.8.0_331
Paul Verest
  • 60,022
  • 51
  • 208
  • 332
phibao37
  • 2,230
  • 4
  • 26
  • 35
  • `[ERROR] ... cannot find symbol [ERROR] symbol: class Responsetatus` you have to fix your code...migration from 2.0.4 to 2.7.0 is a huge step.. I strongly recommend to read the release notes for the releases in between... and go step by step... 2.0.X to 2.1.X, 2.1.X to 2.2.X etc. Also use most recent version of Maven... etc. also `However, when I migrated to Spring Boot 2.7.0, it will not work anymore. The output will be as follow:` what does that mean... the package has been generated etc. and there had a been a lot of changes. in between... – khmarbaise Jun 02 '22 at 07:03
  • @khmarbaise class `Responsetatus` is in project "monitoring" and it can compile successfully without problem. – phibao37 Jun 02 '22 at 07:22
  • The error message tells something different ? It would be helpful to post more of the logs instead of tiny excerpts... – khmarbaise Jun 02 '22 at 07:23
  • @khmarbaise I updated more detail log. – phibao37 Jun 02 '22 at 07:44
  • `WebsocketManager.java:[26,64] package [my package].monitoring.service.customer does not exist` this is the problem you have to fix... – khmarbaise Jun 02 '22 at 07:51
  • It is noted that all symbols that is not found when compiling project "simulator" (`cannot find symbol XXX`) is come from project "monitoring", which is built successfully – phibao37 Jun 02 '22 at 07:51
  • That means you don't have defined the correct dependency or something else is wrong ? – khmarbaise Jun 02 '22 at 07:59
  • This path: `src/monitoring/pom.xml` looks strange to me? – khmarbaise Jun 02 '22 at 08:00
  • The issue come from the "spring-boot-maven-plugin" definition in the POM file. In Spring documentation (https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/htmlsingle/#goals-repackage-parameters-details-classifier), I expect that it will built 2 files: "monitoring.jar" (small file size, used for compiling "simulator"), "monitoring_flat.jar" (big file size). However, in Spring Boot 2.7.0, the file "monitoring.jar" become big file size, similar with file "monitoring_flat.jar", which is not expected – phibao37 Jun 02 '22 at 08:19
  • Your build does not work... the spring-boot-maven-plugin is someting different..first fix you build issues... – khmarbaise Jun 02 '22 at 08:43
  • My question is that the build work for Spring Boot 2.0.4, but doesn't work for 2.7.0. So I post it here for help. In Eclipse, it still works fine and I can run the project "simulator". Why you think that "the spring-boot-maven-plugin" is not related? – phibao37 Jun 02 '22 at 09:14
  • 1
    I will create a sample project in Github for reference – phibao37 Jun 02 '22 at 09:16
  • I found the solution, which is described in the Answer section. – phibao37 Jun 02 '22 at 11:50

3 Answers3

3

Add Following to monitor

<properties>
    <spring-boot.repackage.skip>true</spring-boot.repackage.skip>
</properties>
Koushik
  • 345
  • 1
  • 7
2

From your log it is seen that repackage is executed twice:

[INFO] --- spring-boot-maven-plugin:2.7.0:repackage (repackage) @ monitoring ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- spring-boot-maven-plugin:2.7.0:repackage (default) @ monitoring ---
[INFO] Attaching repackaged archive ...\src\monitoring\target\monitoring-flat.jar with classifier flat

So for the second time, it will do harm

See https://docs.spring.io/spring-boot/docs/2.7.x/maven-plugin/reference/htmlsingle/#packaging

If you are using spring-boot-starter-parent, such execution is already pre-configured with a repackage execution ID so that only the plugin definition should be added.

That is if you are using Spring parent, that adding plugin like this is enough (and so is written in the doc start, and so is produced by https://start.spring.io/ new Spring project)

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

Or again at https://docs.spring.io/spring-boot/docs/current/reference/html/getting-started.html#getting-started.first-application.executable-jar

The spring-boot-starter-parent POM includes configuration to bind the repackage goal.

P.S.

And actually you don't need any extra configuration for spring-boot-maven-plugin, you just rename

monitoring.jar -> monitoring-fat.jar
monitoring.jar.original -> monitoring.jar

Note that industry name is fat .jar, not flat .jar, see What is a fat JAR?

So may be better rename like

monitoring.jar.original -> monitoring-skinny.jar
Paul Verest
  • 60,022
  • 51
  • 208
  • 332
0

I found the solution based on following reference:
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.1-Release-Notes
https://docs.spring.io/spring-boot/docs/2.1.4.RELEASE/maven-plugin/examples/repackage-classifier.html

Maven Plugin
The finalName property is no longer customizable to align with the behavior of standard Maven plugins.

If you were customizing the repackage goal, the main execution has now an id of repackage that must be specified, see the updated sample.

It is simple, just add the <id>repackage</id> to the file src/monitoring/pom.xml, then it will work

phibao37
  • 2,230
  • 4
  • 26
  • 35
  • This can not explain the compile errors... – khmarbaise Jun 02 '22 at 12:15
  • I don't know how to explain detail, but you can refer this: https://www.baeldung.com/spring-boot-repackage-vs-mvn-package – phibao37 Jun 02 '22 at 12:53
  • The project "simulator" depends on JAR file "monitoring.jar" for compiling. If the file "monitoring.jar" is NOT a "Repackaged JAR File" (normally file size smaller than 1Mb), it will work. But if "monitoring.jar" is a "Repackaged JAR File" (normally file size greater than 1Mb), it will not work. – phibao37 Jun 02 '22 at 12:54
  • The structure of "Repackaged JAR File" will be something like "BOOT-INF/classes/my/company/package_name/Monitoring.class", it cannot be used by another project for compiling. – phibao37 Jun 02 '22 at 12:58
  • The correct structure should be something like "my/company/package_name/Monitoring.class" – phibao37 Jun 02 '22 at 13:01
  • Ah that's what I expected that your dependency using the spring boot generated jar instead of the usual jar file... but by default the spring-boot-maven-plugin does not replace the main artifact of the build (the consumable jar file) only if something has been configured to replace that (what you can do) which is not shown in the posted pom files... – khmarbaise Jun 02 '22 at 13:12