From 51e6eda88a1a4dc940d965edcd8aca26fa114ba1 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 27 May 2015 11:11:19 +0200 Subject: [PATCH] Update documentation for spring.main.sources Closes gh-2851 --- .../appendix-application-properties.adoc | 2 +- spring-boot-docs/src/main/asciidoc/howto.adoc | 24 +++++++++++++++++++ ...itional-spring-configuration-metadata.json | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 517de871e30..6035f5c3d56 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -40,7 +40,7 @@ content into your application; rather pick only the properties that you need. spring.profiles.include= # unconditionally activate the specified comma separated profiles # APPLICATION SETTINGS ({sc-spring-boot}/SpringApplication.{sc-ext}[SpringApplication]) - spring.main.sources= + spring.main.sources= # sources (class name, package name or XML resource location) to include spring.main.web-environment= # detect by default spring.main.show-banner=true spring.main....= # see class for all properties diff --git a/spring-boot-docs/src/main/asciidoc/howto.adoc b/spring-boot-docs/src/main/asciidoc/howto.adoc index 73d272f38b1..494e3c4b5d9 100644 --- a/spring-boot-docs/src/main/asciidoc/howto.adoc +++ b/spring-boot-docs/src/main/asciidoc/howto.adoc @@ -132,6 +132,30 @@ not be a web application. NOTE: The example above also demonstrates how flexible binding allows the use of underscores (`_`) as well as dashes (`-`) in property names. +Properties defined in external configuration overrides the values specified via the Java +API with the notable exception of the sources used to create the `ApplicationContext`. Let's +consider this application + +[source,java,indent=0] +---- + new SpringApplicationBuilder() + .showBanner(false) + .sources(demo.MyApp.class) + .run(args); +---- + +used with the following configuration: + +[source,properties,indent=0,subs="verbatim,quotes,attributes"] +---- + spring.main.sources=com.acme.Config,com.acme.ExtraConfig + spring.main.show-banner=true +---- + +The actual application will _not_ show the banner and use three sources for the +`ApplicationContext` (in that order): `demo.MyApp`, `com.acme.Config`, +`com.acme.ExtraConfig`. + [[howto-change-the-location-of-external-properties]] === Change the location of external properties of an application By default properties from different sources are added to the Spring `Environment` in a diff --git a/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json b/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json index 548fb91f342..d46a7a18c42 100644 --- a/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json +++ b/spring-boot/src/main/resources/META-INF/additional-spring-configuration-metadata.json @@ -89,7 +89,7 @@ "name": "spring.main.sources", "type": "java.util.Set", "sourceType": "org.springframework.boot.SpringApplication", - "description": "Sources (class name, package name or XML resource location) used to create the ApplicationContext." + "description": "Sources (class name, package name or XML resource location) to include in the ApplicationContext." }, { "name": "spring.main.web-environment",