Load an external jar from a Spring Boot fat jar

The fat jar of Spring Boot contains the jar of the dependent library, but I will describe how to load the external jar at runtime.

It is not often used, but it is used when the library provides different jars for each environment.

environment

Setting method

By default, JarLauncher is used to launch the Executable Jar, and it goes underBOOT-INF / lib /in the jar. Use PropertiesLauncher instead to change the classpath etc. at runtime.

build.gradle settings

bootJar {
    manifest {
        attributes 'Main-Class': 'org.springframework.boot.loader.PropertiesLauncher'
    }
}

Specifying loader.path

Specify the classpath you want to add with the loader.path property. The environment variable LOADER_PATH may be used. Thankfully, you can also specify a directory and it will recursively scan the jar or zip file.

export LOADER_PATH=/develop
java -jar app.jar

reference

Recommended Posts

Load an external jar from a Spring Boot fat jar
From creating a Spring Boot project to running an application with VS Code
Include external jar in package with Spring boot2 + Maven3
Send a command to Spigot from an external process
From building an AWS cloud environment to deploying a Spring Boot app (for beginners)
Try Spring Boot from 0 to 100.
[Spring Boot] Send an email
Spring Boot External setting priority
Create an app with Spring Boot 2
02. I made an API to connect to MySQL (MyBatis) from Spring Boot
Create an app with Spring Boot
Upgrade spring boot from 1.5 series to 2.0 series
A memo that touched Spring Boot
Spring Boot starting from zero Part 2
Spring Boot starting from zero Part 1
Personal memo Features of Spring Boot (mainly from a DI point of view)
Story when moving from Spring Boot 1.5 to 2.1
Changes when migrating from Spring Boot 1.5 to Spring Boot 2.0
Changes when migrating from Spring Boot 2.0 to Spring Boot 2.2
03. I sent a request from Spring Boot to the zip code search API
Create a website with Spring Boot + Gradle (jdk1.8.x)
Create a simple search app with Spring Boot
Use Thymeleaf text template mode from Spring Boot
Run a Spring Boot project in VS Code
Create a Spring Boot application using IntelliJ IDEA
How to add a classpath in Spring Boot
Java tips-Create a Spring Boot project in Gradle
An introduction to Spring Boot + in-memory data grid
[Java] Get a random value from an array
Deploy a Spring Boot application on Elastic Beanstalk
◆ Get API created by Spring Boot from React
Create a web api server with spring boot
Load images from external sites / domains with Playframework2
Create a Spring Boot development environment with docker
File path is not recognized when executing an external command from a Java application