PropertiesLauncher Features
| This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Boot 4.1.1! |
PropertiesLauncher has a few special features that can be enabled with external properties (System properties, environment variables, manifest entries, or loader.properties).
The following table describes these properties:
| Key | Purpose |
|---|---|
loader.path |
Comma-separated Classpath, such as lib,${HOME}/app/lib. Earlier entries take precedence, like a regular -classpath on the javac command line. |
loader.home |
Used to resolve relative paths in loader.path. For example, given loader.path=lib, then ${loader.home}/lib is a classpath location (along with all jar files in that directory). This property is also used to locate a loader.properties file, as in the following example /opt/app It defaults to ${user.dir}. |
loader.args |
Default arguments for the main method (space separated). |
loader.main |
Name of main class to launch (for example, com.app.Application). |
loader.config.name |
Name of properties file (for example, launcher). It defaults to loader. |
loader.config.location |
Path to properties file (for example, classpath:loader.properties). It defaults to loader.properties. |
loader.system |
Boolean flag to indicate that all properties should be added to System properties. It defaults to false. |
When specified as environment variables or manifest entries, the following names should be used:
| Key | Manifest entry | Environment variable |
|---|---|---|
loader.path |
Loader-Path |
LOADER_PATH |
loader.home |
Loader-Home |
LOADER_HOME |
loader.args |
Loader-Args |
LOADER_ARGS |
loader.main |
Start-Class |
LOADER_MAIN |
loader.config.location |
Loader-Config-Location |
LOADER_CONFIG_LOCATION |
loader.system |
Loader-System |
LOADER_SYSTEM |
Build plugins automatically move the Main-Class attribute to Start-Class when the uber jar is built. If you use that, specify the name of the class to launch by using the Main-Class attribute and leaving out Start-Class. |
The following rules apply to working with PropertiesLauncher:
loader.propertiesis searched for inloader.home, then in the root of the classpath, and then inclasspath:/BOOT-INF/classes. The first location where a file with that name exists is used.loader.homeis the directory location of an additional properties file (overriding the default) only whenloader.config.locationis not specified.loader.pathcan contain directories (which are scanned recursively for jar and zip files), archive paths, a directory within an archive that is scanned for jar files (for example,dependencies.jar!/lib), or wildcard patterns (for the default JVM behavior). Archive paths can be relative toloader.homeor anywhere in the file system with ajar:file:prefix.loader.path(if empty) defaults toBOOT-INF/lib(meaning a local directory or a nested one if running from an archive). Because of this,PropertiesLauncherbehaves the same asJarLauncherwhen no additional configuration is provided.loader.pathcan not be used to configure the location ofloader.properties(the classpath used to search for the latter is the JVM classpath whenPropertiesLauncheris launched).- Placeholder replacement is done from System and environment variables plus the properties file itself on all values before use.
-
The search order for properties (where it makes sense to look in more than one place) is environment variables, system properties,
loader.properties, the exploded archive manifest, and the archive manifest. -
Related Spring Documentation
- Spring Boot
- Spring Framework
- Spring Cloud
- Spring Cloud Build
- Spring Cloud Bus
- Spring Cloud Circuit Breaker
- Spring Cloud Commons
- Spring Cloud Config
- Spring Cloud Consul
- Spring Cloud Contract
- Spring Cloud Function
- Spring Cloud Gateway
- Spring Cloud Kubernetes
- Spring Cloud Netflix
- Spring Cloud OpenFeign
- Spring Cloud Stream
- Spring Cloud Task
- Spring Cloud Vault
- Spring Cloud Zookeeper
- Spring Data
- Spring Integration
- Spring Batch
- Spring Security
- Spring AI
- Spring AMQP
- Spring CLI
- Spring GraphQL
- Spring for Apache Kafka
- Spring Modulith
- Spring for Apache Pulsar
- Spring Shell All Docs...
