heldt heldt - 12 days ago 6
Java Question

spring boot application as maven depency

I have an existing spring boot application that I would like to have as a dependency in my other project. I want to use classes from the spring boot application.

Maven downloads the artifact and all checks out but intellij and eclipse can't find the classes.

When I dig in to the external libs I find all classes in the "BOOT-INF" folder inside of the jar. Other jars have their packages in the root of the jar, so I figure this is the problem.

What can I do fix this?

I can change stuff in the original spring boot application.

Answer

This is covered in Spring Boot's documentation. In a nutshell, you need to configure your build to use a classifier for the repackaged fat jar so that you can use the original jar as a dependency:

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