I have a problem with a Multi-Module Spring-Boot Application.
I have one Module that I use for Services, the core-Module. And one module for View-Related Classes, the web-Module. The are both in a parent-Module, where I add the dependencies, like the "spring-boot-starter" and that can be used by both modules.
Now to the problem:
I want to run the web-Module with the embedded Tomcat and have the core-Module as a dependency in the web-module.
In other Spring projects I would just include the maven-jar-plugin and create a jar of the core-Module.
The problem in this Spring-Boot project is that the maven-jar-plugin is already configured, in the "spring-boot-starter". And it needs a mainClass, which only the web-module has.
Small excerpt from the "spring-boot-starter"-POM
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>${start-class}</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
Is there a way to package the core-Module as a JAR without needing a "start-class" in that module?
FYI: In simple terms, the difference between a JAR file and a Runnable JAR is that while a JAR file is a Java application which requires a command line to run, a runnable JAR file can be directly executed by double clicking it.
app-plain. jar is the archive produced by the jar task. This is a plain or standard jar file that contains only the module's classes and resources. You can learn a bit more about this in the documentation for Spring Boot's Gradle plugin.
You can just disable the spring-boot-maven plugin this way.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
To create simple jar update
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
To
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<classifier>exec</classifier>
</configuration>
</plugin>
For more details please visit below Spring URL:- https://docs.spring.io/spring-boot/docs/1.1.2.RELEASE/reference/html/howto-build.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With