Reputation: 2350
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:
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:
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:
Upvotes: 3
Views: 13471
Reputation: 64012
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>
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
Upvotes: 3
Reputation: 352
Add Following to monitor
<properties>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
</properties>
Upvotes: 4
Reputation: 2350
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
Upvotes: 1