Usually, when developing a Microservice you want to expose its interfaces via REST to other Microservices or to the frontend. However, you might want to develop a library that uses the functionality of Spring Boot.
By adding a Maven repackage goal to your pom.xml, your module will be packaged as a Java module instead of a Spring Boot module. This allows you to include the JAR into other Spring Boot modules as dependency. Nevertheless, you should keep in mind that this is an unconventional solution.
Build block of maven pom
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> <configuration> <classifier>exec</classifier> </configuration> </execution> </executions> </plugin> </plugins> </build>