3

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
heldt
  • 4,166
  • 7
  • 39
  • 67
  • Maybe you can add a build configuration and package it as JAR? – Jay Nov 25 '16 at 11:40
  • 1
    You shouldn't do that ast that would include the spring-boot jar inside a spring boot jar... Making your app massive... If you need that, extract the classes you need, create a simple shared jar and use that in both projects. – M. Deinum Nov 25 '16 at 11:41
  • Yeah I know. In retrospect I should have moduled the application. This is the systemtest environment so I don't really care about size of jars etc. Hoped for small hack to fix it :) – heldt Nov 25 '16 at 11:46

1 Answers1

8

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>
Andy Wilkinson
  • 108,729
  • 24
  • 257
  • 242