Skip to content
Advertisement

BootJar didn’t create BOOT-INF folder after spring boot migration from 1.5.8 to 2.1.14-RELEASE

I have done the migration of the Spring Boot Application from 1.5.8 to 2.1.14-RELEASE and using gradle as a build script. I am using spring-boot-gradle-plugin and spring-boot-dependency-management plugins. In our spring boot project, we are creating multiple executable jar files by creating tasks for each jar as below

JavaScript

In the above code after executing either gradle assemble, It has created two executable jar files eurekaJar-0.0.1.jar, oAuthConfigJar-0.0.1.jar.

Here is my question:

Before the spring boot migration, in the above jars the folder structure is as below:

eurekaJar-0.0.1.jar 
   -- org
   -- META-INF
   -- BOOT-INT
         -- lib
              -- dependencies (jars)
         -- classes
               -- applicationclasses

after the migration below is the folder structure

eurekaJar-0.0.1.jar 
   -- org
   -- META-INF
   -- applicationclasses

so after the migration there is no BOOT-INF folder and dependencies(lib folder)

Because of the above issue my executable jar is not running.

Any comment is appreciated.

Advertisement

Answer

Rather than using from, which will add files directly to the jar, you should configure the classpath of the BootJar tasks. Jar files on the classpath will be packaged in BOOT-INF/lib and directories will be packaged in BOOT-INF/classes.

For reference, you can see how Spring Boot configures the classpath of the default bootJar task in its own plugin here. From what you’ve shown above, you probably want to use the runtime classpath of the main source set too.

Here’s a complete example for your eurekaAppJar:

JavaScript

This jar can then be built with the following command:

JavaScript

Its classes and dependencies are packaged in BOOT-INF/classes and BOOT-INF/lib respectively:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement