You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue: application.yml Not Loaded Correctly in Fat JAR Built with Shadow Plugin
Description
I encountered an issue where the application.yml file is not being loaded correctly when packaging a Spring Boot application into a fat JAR using the com.github.johnrengelman.shadow plugin.
Steps to Reproduce
Project Setup:
Spring Boot version:2.7.7
Gradle version:8.10 (Replace with your version)
Shadow plugin version:8.1.1
Java version:17
Build the Fat JAR:
I used the following Gradle configuration to build the fat JAR:
plugins {
id 'application'
id 'org.openjfx.javafxplugin' version '0.0.13'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}
shadowJar {
archiveClassifier.set('all')
mergeServiceFiles()
from('src/main/resources') {
into 'BOOT-INF/classes/'
include '**/*.yml'
}
}
application {
mainClass ='com.jawwad.posrestaurant.PosRestaurantApplication'
}
The application.yml file is present in both the root and BOOT-INF/classes/ directories within the JAR.
Despite this, Spring Boot fails to resolve placeholders defined in application.yml (e.g., ${backend.baseurl}) during the application startup.
The application throws an IllegalArgumentException indicating that the placeholder could not be resolved.
Expected Behavior
Spring Boot should correctly load application.yml from BOOT-INF/classes/ and resolve all placeholders defined within it.
Additional Information
The application runs correctly when built using the bootJar task or when using the non-fat JAR.
The issue appears to be specific to the configuration when using the Shadow plugin.
Logs and Output
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'backend.baseurl' in value "${backend.baseurl}"
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:180)
...
The text was updated successfully, but these errors were encountered:
Issue:
application.yml
Not Loaded Correctly in Fat JAR Built with Shadow PluginDescription
I encountered an issue where the
application.yml
file is not being loaded correctly when packaging a Spring Boot application into a fat JAR using thecom.github.johnrengelman.shadow
plugin.Steps to Reproduce
Project Setup:
2.7.7
8.10
(Replace with your version)8.1.1
17
Build the Fat JAR:
I used the following Gradle configuration to build the fat JAR:
Run the Application:
After building the fat JAR, I executed it using:
Observed Behavior
application.yml
file is present in both the root andBOOT-INF/classes/
directories within the JAR.application.yml
(e.g.,${backend.baseurl}
) during the application startup.IllegalArgumentException
indicating that the placeholder could not be resolved.Expected Behavior
application.yml
fromBOOT-INF/classes/
and resolve all placeholders defined within it.Additional Information
bootJar
task or when using the non-fat JAR.Logs and Output
The text was updated successfully, but these errors were encountered: