mmaceachran
mmaceachran

Reputation: 3348

Create an Spring Boot Executable jar AND a regular library jar

I have a regular Java project that creates a jar file that is a library of stuff that is used in a webapp. It's a Spring Boot starter that creates a jar. Simple stuff.

I wanted to be able to run this as a stand alone executable jar file. So I write a standard Application.java that implements CommandLineRunner and I add this to my plugins:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>

and presto, my jar is executable.

However, that plugin changes the directory structure such that it is no longer a regular library jar, and my webapplication fails to find the classes in it. When I remove the plugin entry in my pom, the webapp works fine, but the jar is no longer executable.

Is it possible to do both? And if so, how?

Upvotes: 2

Views: 726

Answers (1)

geneSummons
geneSummons

Reputation: 925

It was possible prior to Spring Boot 1.4.1, but not since. 1.4.1 changed the directory structure in an executable jar. for 1.4.1 and after, a jar can be executable or a library but not both.

If you really need the same jar to be both executable and a library, you'll need to revert to Spring Boot 1.4.0 or earlier.

Upvotes: 1

Related Questions