We've recently upgraded to Spring Boot 2.3, and moved from the Palantir Docker plugin to the Spring Boot CNB plugin.
Default application configuration was stored in classpath:/application.yml
(from src/main/resources/application.yml
) with the customised configuration being mounted into the container using docker run -v $PWD/application.yml:/application.yml ...
. This would load both config files:
[ main] o.s.b.c.c.ConfigFileApplicationListener : Loaded config file 'file:./application.yml' (file:./application.yml)
[ main] o.s.b.c.c.ConfigFileApplicationListener : Loaded config file 'jar:file:/app.jar!/BOOT-INF/classes!/application.yml' (classpath:/application.yml)
With the Spring Boot CNB plugin the application appears to live in /workspace
, so adjusting our run command to docker run -v $PWD/application.yml:/workspace/application.yml ...
results in the mounted config file being loaded twice, while the one from the classpath is not loaded at all.
[ main] o.s.b.c.c.ConfigFileApplicationListener : Loaded config file 'file:./application.yml' (file:./application.yml)
[ main] o.s.b.c.c.ConfigFileApplicationListener : Loaded config file 'file:/workspace/application.yml' (classpath:/application.yml)
When starting without an additional configuration file, we see the default configuration file loaded as expected:
[ main] o.s.b.c.c.ConfigFileApplicationListener : Loaded config file 'file:/workspace/BOOT-INF/classes/application.yml' (classpath:/application.yml)
The classpath reported when we set debug: true
does not include /workspace
:
file:/workspace/BOOT-INF/classes/
file:/workspace/BOOT-INF/lib/spring-cloud-bindings-1.7.1.jar
file:/workspace/BOOT-INF/lib/graphql-spring-boot-starter-11.0.0.jar
file:/workspace/BOOT-INF/lib/graphql-spring-boot-autoconfigure-11.0.0.jar
file:/workspace/BOOT-INF/lib/spring-boot-properties-migrator-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-configuration-metadata-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-starter-actuator-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-starter-data-jpa-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/liquibase-core-3.10.3.jar
file:/workspace/BOOT-INF/lib/spring-boot-starter-security-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-starter-thymeleaf-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/thymeleaf-spring4-3.0.11.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-starter-websocket-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-starter-web-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-starter-mail-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-actuator-autoconfigure-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-starter-json-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/vfs-azure-3.1.4.jar
file:/workspace/BOOT-INF/lib/azure-storage-blob-12.5.0.jar
file:/workspace/BOOT-INF/lib/azure-storage-common-12.5.0.jar
file:/workspace/BOOT-INF/lib/azure-core-http-netty-1.4.0.jar
file:/workspace/BOOT-INF/lib/azure-core-1.3.0.jar
file:/workspace/BOOT-INF/lib/jackson-datatype-jsr310-2.10.5.jar
file:/workspace/BOOT-INF/lib/jackson-datatype-jts-1.0-2.7.jar
file:/workspace/BOOT-INF/lib/graphql-kickstart-spring-boot-starter-tools-11.0.0.jar
file:/workspace/BOOT-INF/lib/graphql-kickstart-spring-boot-autoconfigure-tools-11.0.0.jar
file:/workspace/BOOT-INF/lib/graphql-java-tools-11.0.0.jar
file:/workspace/BOOT-INF/lib/jackson-module-kotlin-2.11.4.jar
file:/workspace/BOOT-INF/lib/graphql-java-servlet-11.0.0.jar
file:/workspace/BOOT-INF/lib/graphql-java-kickstart-11.0.0.jar
file:/workspace/BOOT-INF/lib/jackson-datatype-jdk8-2.11.4.jar
file:/workspace/BOOT-INF/lib/jackson-module-parameter-names-2.11.4.jar
file:/workspace/BOOT-INF/lib/vfs-s3-4.3.2.jar
file:/workspace/BOOT-INF/lib/commons-vfs2-2.6.0.jar
file:/workspace/BOOT-INF/lib/hadoop-hdfs-client-3.2.1.jar
file:/workspace/BOOT-INF/lib/aws-java-sdk-s3-1.11.762.jar
file:/workspace/BOOT-INF/lib/aws-java-sdk-kms-1.11.762.jar
file:/workspace/BOOT-INF/lib/aws-java-sdk-core-1.11.762.jar
file:/workspace/BOOT-INF/lib/jmespath-java-1.11.762.jar
file:/workspace/BOOT-INF/lib/jackson-dataformat-cbor-2.11.4.jar
file:/workspace/BOOT-INF/lib/jackson-dataformat-xml-2.11.4.jar
file:/workspace/BOOT-INF/lib/jackson-module-jaxb-annotations-2.11.4.jar
file:/workspace/BOOT-INF/lib/jackson-databind-2.10.5.jar
file:/workspace/BOOT-INF/lib/commons-collections4-4.1.jar
file:/workspace/BOOT-INF/lib/liquibase-groovy-dsl-2.1.2.jar
file:/workspace/BOOT-INF/lib/modelmapper-2.3.8.jar
file:/workspace/BOOT-INF/lib/graphql-java-extended-scalars-1.0.jar
file:/workspace/BOOT-INF/lib/jts-io-common-1.16.0.jar
file:/workspace/BOOT-INF/lib/spring-retry-1.3.1.jar
file:/workspace/BOOT-INF/lib/spring-boot-starter-data-redis-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-starter-validation-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-starter-aop-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-starter-jdbc-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-starter-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/snakeyaml-1.27.jar
file:/workspace/BOOT-INF/lib/sentry-spring-1.7.30.jar
file:/workspace/BOOT-INF/lib/sentry-logback-1.7.30.jar
file:/workspace/BOOT-INF/lib/hibernate-envers-5.4.32.Final.jar
file:/workspace/BOOT-INF/lib/hibernate-spatial-5.4.32.Final.jar
file:/workspace/BOOT-INF/lib/java-object-diff-0.95.jar
file:/workspace/BOOT-INF/lib/log4j-core-2.11.0.jar
file:/workspace/BOOT-INF/lib/spring-boot-starter-logging-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/log4j-to-slf4j-2.13.3.jar
file:/workspace/BOOT-INF/lib/log4j-api-2.11.0.jar
file:/workspace/BOOT-INF/lib/jaxb-impl-2.1.2.jar
file:/workspace/BOOT-INF/lib/hibernate-core-5.4.32.Final.jar
file:/workspace/BOOT-INF/lib/jaxb-api-2.3.1.jar
file:/workspace/BOOT-INF/lib/gt-xsd-kml-23.2.jar
file:/workspace/BOOT-INF/lib/stripe-java-20.47.0.jar
file:/workspace/BOOT-INF/lib/spring-session-data-redis-2.3.3.RELEASE.jar
file:/workspace/BOOT-INF/lib/jedis-3.3.0.jar
file:/workspace/BOOT-INF/lib/flying-saucer-pdf-openpdf-9.1.20.jar
file:/workspace/BOOT-INF/lib/tika-core-1.22.jar
file:/workspace/BOOT-INF/lib/micrometer-registry-statsd-1.5.14.jar
file:/workspace/BOOT-INF/lib/mapstruct-1.4.1.Final.jar
file:/workspace/BOOT-INF/lib/swagger-annotations-1.5.20.jar
file:/workspace/BOOT-INF/lib/mariadb-java-client-2.3.0.jar
file:/workspace/BOOT-INF/lib/postgresql-42.2.18.jar
file:/workspace/BOOT-INF/lib/h2gis-1.5.0.jar
file:/workspace/BOOT-INF/lib/h2gis-utilities-1.5.0.jar
file:/workspace/BOOT-INF/lib/h2-1.4.197.jar
file:/workspace/BOOT-INF/lib/commons-compress-1.20.jar
file:/workspace/BOOT-INF/lib/micrometer-core-1.5.14.jar
file:/workspace/BOOT-INF/lib/jakarta.transaction-api-1.3.3.jar
file:/workspace/BOOT-INF/lib/jakarta.persistence-api-2.2.3.jar
file:/workspace/BOOT-INF/lib/spring-data-jpa-2.3.9.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-aspects-5.2.15.RELEASE.jar
file:/workspace/BOOT-INF/lib/logback-classic-1.2.3.jar
file:/workspace/BOOT-INF/lib/thymeleaf-spring5-3.0.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/thymeleaf-extras-java8time-3.0.4.RELEASE.jar
file:/workspace/BOOT-INF/lib/thymeleaf-3.0.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/graphql-java-16.1.jar
file:/workspace/BOOT-INF/lib/sentry-1.7.30.jar
file:/workspace/BOOT-INF/lib/geolatte-geom-1.8.0.jar
file:/workspace/BOOT-INF/lib/spring-data-redis-2.3.9.RELEASE.jar
file:/workspace/BOOT-INF/lib/cts-1.5.2.jar
file:/workspace/BOOT-INF/lib/poly2tri-core-0.1.2.jar
file:/workspace/BOOT-INF/lib/HikariCP-3.4.5.jar
file:/workspace/BOOT-INF/lib/spring-data-keyvalue-2.3.9.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-data-commons-2.3.9.RELEASE.jar
file:/workspace/BOOT-INF/lib/jul-to-slf4j-1.7.30.jar
file:/workspace/BOOT-INF/lib/slf4j-api-1.7.30.jar
file:/workspace/BOOT-INF/lib/spring-security-config-5.3.9.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-security-web-5.3.9.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-webmvc-5.2.15.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-websocket-5.2.15.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-context-support-5.2.15.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-autoconfigure-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-actuator-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-security-core-5.3.9.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-context-5.2.15.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-aop-5.2.15.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-boot-starter-tomcat-2.3.12.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-web-5.2.15.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-messaging-5.2.15.RELEASE.jar
file:/workspace/BOOT-INF/lib/jakarta.mail-1.6.7.jar
file:/workspace/BOOT-INF/lib/jackson-annotations-2.11.4.jar
file:/workspace/BOOT-INF/lib/gt-xsd-core-23.2.jar
file:/workspace/BOOT-INF/lib/gt-xml-23.2.jar
file:/workspace/BOOT-INF/lib/gt-main-23.2.jar
file:/workspace/BOOT-INF/lib/jackson-core-2.11.4.jar
file:/workspace/BOOT-INF/lib/groovy-sql-2.5.14.jar
file:/workspace/BOOT-INF/lib/groovy-2.5.14.jar
file:/workspace/BOOT-INF/lib/commons-text-1.6.jar
file:/workspace/BOOT-INF/lib/gt-referencing-23.2.jar
file:/workspace/BOOT-INF/lib/gt-metadata-23.2.jar
file:/workspace/BOOT-INF/lib/commons-lang3-3.10.jar
file:/workspace/BOOT-INF/lib/kotlin-reflect-1.3.72.jar
file:/workspace/BOOT-INF/lib/kotlin-stdlib-1.3.72.jar
file:/workspace/BOOT-INF/lib/kotlinx-coroutines-jdk8-1.3.8.jar
file:/workspace/BOOT-INF/lib/kotlinx-coroutines-reactive-1.3.8.jar
file:/workspace/BOOT-INF/lib/kotlinx-coroutines-core-1.3.8.jar
file:/workspace/BOOT-INF/lib/hibernate-validator-6.1.7.Final.jar
file:/workspace/BOOT-INF/lib/classmate-1.5.1.jar
file:/workspace/BOOT-INF/lib/okhttp-3.14.9.jar
file:/workspace/BOOT-INF/lib/json-simple-1.1.1.jar
file:/workspace/BOOT-INF/lib/jts-core-1.18.1.jar
file:/workspace/BOOT-INF/lib/logback-core-1.2.3.jar
file:/workspace/BOOT-INF/lib/hibernate-commons-annotations-5.1.2.Final.jar
file:/workspace/BOOT-INF/lib/jboss-logging-3.4.2.Final.jar
file:/workspace/BOOT-INF/lib/dom4j-2.1.3.jar
file:/workspace/BOOT-INF/lib/javax.activation-api-1.2.0.jar
file:/workspace/BOOT-INF/lib/gt-opengis-23.2.jar
file:/workspace/BOOT-INF/lib/net.opengis.ows-23.2.jar
file:/workspace/BOOT-INF/lib/org.w3.xlink-23.2.jar
file:/workspace/BOOT-INF/lib/jai_core-1.1.3.jar
file:/workspace/BOOT-INF/lib/gson-2.8.7.jar
file:/workspace/BOOT-INF/lib/spring-session-core-2.3.3.RELEASE.jar
file:/workspace/BOOT-INF/lib/lettuce-core-5.3.7.RELEASE.jar
file:/workspace/BOOT-INF/lib/commons-pool2-2.8.1.jar
file:/workspace/BOOT-INF/lib/openpdf-1.3.11.jar
file:/workspace/BOOT-INF/lib/flying-saucer-core-9.1.20.jar
file:/workspace/BOOT-INF/lib/jakarta.el-3.0.3.jar
file:/workspace/BOOT-INF/lib/checker-qual-3.5.0.jar
file:/workspace/BOOT-INF/lib/h2gis-api-1.5.0.jar
file:/workspace/BOOT-INF/lib/jakarta.annotation-api-1.3.5.jar
file:/workspace/BOOT-INF/lib/spring-orm-5.2.15.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-jdbc-5.2.15.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-tx-5.2.15.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-oxm-5.2.15.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-beans-5.2.15.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-expression-5.2.15.RELEASE.jar
file:/workspace/BOOT-INF/lib/spring-core-5.2.15.RELEASE.jar
file:/workspace/BOOT-INF/lib/HdrHistogram-2.1.12.jar
file:/workspace/BOOT-INF/lib/LatencyUtils-2.0.3.jar
file:/workspace/BOOT-INF/lib/aspectjweaver-1.9.6.jar
file:/workspace/BOOT-INF/lib/javassist-3.27.0-GA.jar
file:/workspace/BOOT-INF/lib/byte-buddy-1.10.22.jar
file:/workspace/BOOT-INF/lib/antlr-2.7.7.jar
file:/workspace/BOOT-INF/lib/jandex-2.2.3.Final.jar
file:/workspace/BOOT-INF/lib/jaxb-runtime-2.3.4.jar
file:/workspace/BOOT-INF/lib/attoparser-2.0.5.RELEASE.jar
file:/workspace/BOOT-INF/lib/unbescape-1.1.6.RELEASE.jar
file:/workspace/BOOT-INF/lib/tomcat-embed-websocket-9.0.46.jar
file:/workspace/BOOT-INF/lib/tomcat-embed-core-9.0.46.jar
file:/workspace/BOOT-INF/lib/jakarta.activation-1.2.2.jar
file:/workspace/BOOT-INF/lib/commons-logging-1.2.jar
file:/workspace/BOOT-INF/lib/graphql-kickstart-spring-support-11.0.0.jar
file:/workspace/BOOT-INF/lib/kotlin-stdlib-common-1.3.72.jar
file:/workspace/BOOT-INF/lib/annotations-13.0.jar
file:/workspace/BOOT-INF/lib/reactor-netty-0.9.20.RELEASE.jar
file:/workspace/BOOT-INF/lib/reactor-core-3.3.17.RELEASE.jar
file:/workspace/BOOT-INF/lib/reactive-streams-1.0.3.jar
file:/workspace/BOOT-INF/lib/java-dataloader-2.2.3.jar
file:/workspace/BOOT-INF/lib/antlr4-runtime-4.8.jar
file:/workspace/BOOT-INF/lib/okhttp-2.7.5.jar
file:/workspace/BOOT-INF/lib/okio-1.17.2.jar
file:/workspace/BOOT-INF/lib/junit-4.13.2.jar
file:/workspace/BOOT-INF/lib/picocontainer-1.2.jar
file:/workspace/BOOT-INF/lib/commons-jxpath-1.3.jar
file:/workspace/BOOT-INF/lib/commons-collections-3.2.2.jar
file:/workspace/BOOT-INF/lib/commons-io-2.6.jar
file:/workspace/BOOT-INF/lib/org.eclipse.emf.ecore.xmi-2.15.0.jar
file:/workspace/BOOT-INF/lib/org.eclipse.emf.ecore-2.15.0.jar
file:/workspace/BOOT-INF/lib/org.eclipse.emf.common-2.15.0.jar
file:/workspace/BOOT-INF/lib/org.eclipse.xsd-2.12.0.jar
file:/workspace/BOOT-INF/lib/spring-jcl-5.2.15.RELEASE.jar
file:/workspace/BOOT-INF/lib/netty-handler-proxy-4.1.65.Final.jar
file:/workspace/BOOT-INF/lib/netty-codec-http2-4.1.65.Final.jar
file:/workspace/BOOT-INF/lib/netty-codec-http-4.1.65.Final.jar
file:/workspace/BOOT-INF/lib/netty-handler-4.1.65.Final.jar
file:/workspace/BOOT-INF/lib/netty-codec-socks-4.1.65.Final.jar
file:/workspace/BOOT-INF/lib/netty-codec-4.1.65.Final.jar
file:/workspace/BOOT-INF/lib/netty-transport-native-epoll-4.1.65.Final-linux-x86_64.jar
file:/workspace/BOOT-INF/lib/netty-transport-native-unix-common-4.1.65.Final.jar
file:/workspace/BOOT-INF/lib/netty-transport-4.1.65.Final.jar
file:/workspace/BOOT-INF/lib/netty-resolver-4.1.65.Final.jar
file:/workspace/BOOT-INF/lib/netty-buffer-4.1.65.Final.jar
file:/workspace/BOOT-INF/lib/netty-common-4.1.65.Final.jar
file:/workspace/BOOT-INF/lib/juniversalchardet-2.3.0.jar
file:/workspace/BOOT-INF/lib/jakarta.validation-api-2.0.2.jar
file:/workspace/BOOT-INF/lib/android-json-0.0.20131108.vaadin1.jar
file:/workspace/BOOT-INF/lib/jakarta.xml.bind-api-2.3.3.jar
file:/workspace/BOOT-INF/lib/txw2-2.3.4.jar
file:/workspace/BOOT-INF/lib/istack-commons-runtime-3.0.12.jar
file:/workspace/BOOT-INF/lib/httpclient-4.5.13.jar
file:/workspace/BOOT-INF/lib/ion-java-1.0.2.jar
file:/workspace/BOOT-INF/lib/joda-time-2.8.1.jar
file:/workspace/BOOT-INF/lib/netty-tcnative-boringssl-static-2.0.39.Final.jar
file:/workspace/BOOT-INF/lib/javax.servlet-api-4.0.1.jar
file:/workspace/BOOT-INF/lib/javax.websocket-api-1.1.jar
file:/workspace/BOOT-INF/lib/hamcrest-core-2.2.jar
file:/workspace/BOOT-INF/lib/xml-commons-resolver-1.2.jar
file:/workspace/BOOT-INF/lib/httpcore-4.4.14.jar
file:/workspace/BOOT-INF/lib/commons-codec-1.14.jar
file:/workspace/BOOT-INF/lib/woodstox-core-6.2.3.jar
file:/workspace/BOOT-INF/lib/stax2-api-4.2.1.jar
file:/workspace/BOOT-INF/lib/hamcrest-2.2.jar
file:/workspace/BOOT-INF/lib/ejml-ddense-0.34.jar
file:/workspace/BOOT-INF/lib/commons-pool-1.6.jar
file:/workspace/BOOT-INF/lib/jgridshift-core-1.2.jar
file:/workspace/BOOT-INF/lib/GeographicLib-Java-1.49.jar
file:/workspace/BOOT-INF/lib/jakarta.activation-api-1.2.2.jar
file:/workspace/BOOT-INF/lib/ejml-core-0.34.jar
file:/workspace/BOOT-INF/lib/systems-common-java8-0.7.2.jar
file:/workspace/BOOT-INF/lib/si-units-java8-0.7.1.jar
file:/workspace/BOOT-INF/lib/uom-se-1.0.8.jar
file:/workspace/BOOT-INF/lib/si-quantity-0.7.1.jar
file:/workspace/BOOT-INF/lib/uom-lib-common-1.0.2.jar
file:/workspace/BOOT-INF/lib/unit-api-1.0.jar
Comment From: nigelsim
As a workaround we've moved our default configuration to /src/main/resources/config/application.yml
. This works, but also exhibits the duplicate loading behaviour.
[ main] o.s.b.c.c.ConfigFileApplicationListener : Loaded config file 'file:./application.yml' (file:./application.yml)
[ main] o.s.b.c.c.ConfigFileApplicationListener : Loaded config file 'file:/workspace/BOOT-INF/classes/config/application.yml' (classpath:/config/application.yml)
[ main] o.s.b.c.c.ConfigFileApplicationListener : Loaded config file 'file:/workspace/application.yml' (classpath:/application.yml)
Comment From: wilkinsona
results in the mounted config file being loaded twice, while the one from the classpath is not loaded at all.
[ main] o.s.b.c.c.ConfigFileApplicationListener : Loaded config file 'file:./application.yml' (file:./application.yml) [ main] o.s.b.c.c.ConfigFileApplicationListener : Loaded config file 'file:/workspace/application.yml' (classpath:/application.yml)
The second line of the output here shows that the config file has been loaded from the classpath.
The classpath reported when we set
debug: true
does not include/workspace
I believe that this is the classpath of Spring Boot's class loader. It doesn't include the entries that are on the classpath of its parent, the app class loader. IIRC, the buildpack uses /workspace
as the working directory and launches the JVM with .
on the classpath. As a result, an application.yml
file in /workspace
is picked up from the classpath. It takes precedence over the file in BOOT-INF/classes
as .
appears on the classpath before BOOT-INF/classes
does due to parent-first class and resource loading.
In your situation, it doesn't appear to be ideal that the working directory is also on the classpath. Unfortunately, that's out of Spring Boot's control so there's nothing that we can do about it here. You may want to raise this with the Paketo team, specifically the Spring Boot buildpack.