3

Can someone give me an understanding of what the Spring Boot Maven plugin actually does? I have been Googling, but most of what I find doesn't give a clear picture.

The impression I have so far is that it can create a "fully executable" jar that does not need to be run via java -jar, and that it's also possible to make a more traditional jar that you would run via java -jar. I'm sure there are other variations of what it can produce as well.

I'm also under the impression that it can package up dependencies and resources. It's not at all clear to me how the resources are "accessed" by the application when it's run.

In either of the outcomes described above do I need just the jar and nothing else (i.e. no resource files, dependency jars, etc.)? In other words, is the jar self-contained? When I've opened the jar up, it does seem that everything it needs is there. Is that really the case?

Now, let's go a little further towards what I'm trying to do. I am writing a set of Spring services with REST APIs. Each service will be run in its own VM (or container - future). The services are packaged into a single jar and the service to be used is selected via Spring profile (i.e. spring.profiles.active=a-profile).

The way I've done things like this before has been to use the Maven assembly plugin to produce an archive (zip) for each separate service and inlcude all of the necessities (dependency jars, resource files, etc.). I'd place it where needed, unpack it, tweak some configuration and run it via an included script.

I'm getting the impression that's not "how it's done" when the Spring Boot Maven plugin is involved.

Joseph Gagnon
  • 1,731
  • 3
  • 30
  • 63

1 Answers1

2

The Spring Boot Maven Plugin provides Spring Boot support in Maven, letting you package executable jar or war archives and run an application “in-place”.

It builds the uber jar which bundles in Tomcat along with your app. If you inspect the contents of the jar with jar -tf <file_name> you will see that the format is a bit different. The Spring Boot classes look normal, but then your project's files are inside a BOOT-INF folder.

Chris Savory
  • 2,597
  • 1
  • 17
  • 27