diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/MessageSourceProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/MessageSourceProperties.java index e2328d99ea..456be83100 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/MessageSourceProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/context/MessageSourceProperties.java @@ -59,7 +59,8 @@ public class MessageSourceProperties { private boolean alwaysUseMessageFormat = false; /** - * Set whether to use the message code as default message instead of throwing a NoSuchMessageException. + * Set whether to use the message code as default message instead of throwing a + * "NoSuchMessageException". Recommended during development only. */ private boolean useCodeAsDefaultMessage = false; @@ -110,4 +111,5 @@ public class MessageSourceProperties { public void setUseCodeAsDefaultMessage(final boolean useCodeAsDefaultMessage) { this.useCodeAsDefaultMessage = useCodeAsDefaultMessage; } + } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/context/MessageSourceAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/context/MessageSourceAutoConfigurationTests.java index dbe60d1e60..4c6c9135d5 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/context/MessageSourceAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/context/MessageSourceAutoConfigurationTests.java @@ -144,14 +144,14 @@ public class MessageSourceAutoConfigurationTests { } @Test - public void testUseCodeAsDefaultMessageDefault() throws Exception { + public void testUseCodeAsDefaultMessageDefault() { load("spring.messages.basename:test/messages"); assertThat(isUseCodeAsDefaultMessage(this.context.getBean(MessageSource.class))) .isFalse(); } @Test - public void testUseCodeAsDefaultMessageOn() throws Exception { + public void testUseCodeAsDefaultMessageOn() { load("spring.messages.basename:test/messages", "spring.messages.use-code-as-default-message:true"); assertThat(isUseCodeAsDefaultMessage(this.context.getBean(MessageSource.class))) 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 6f7c6a968a..66fb7540a4 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -117,6 +117,7 @@ content into your application; rather pick only the properties that you need. spring.messages.cache-seconds=-1 # Loaded resource bundle files cache expiration, in seconds. When set to -1, bundles are cached forever. spring.messages.encoding=UTF-8 # Message bundles encoding. spring.messages.fallback-to-system-locale=true # Set whether to fall back to the system Locale if no files for a specific Locale have been found. + spring.messages.use-code-as-default-message=false # Set whether to use the message code as default message instead of throwing a "NoSuchMessageException". Recommended during development only. # OUTPUT spring.output.ansi.enabled=detect # Configure the ANSI output.