diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestProperties.java
index 1a7c378a13f..2005f90773c 100644
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestProperties.java
+++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestProperties.java
@@ -50,12 +50,14 @@ public class RepositoryRestProperties {
private String pageParamName;
/**
- * Name of the URL query string parameter that indicates how many results to return at once.
+ * Name of the URL query string parameter that indicates how many results to return at
+ * once.
*/
private String limitParamName;
/**
- * Name of the URL query string parameter that indicates what direction to sort results.
+ * Name of the URL query string parameter that indicates what direction to sort
+ * results.
*/
private String sortParamName;
@@ -75,44 +77,11 @@ public class RepositoryRestProperties {
private Boolean returnBodyOnUpdate;
/**
- * Enable enum value translation via the Spring Data REST default resource bundle. Will use
- * the fully qualified enum name as key.
+ * Enable enum value translation via the Spring Data REST default resource bundle.
+ * Will use the fully qualified enum name as key.
*/
private Boolean enableEnumTranslation;
- public void applyTo(RepositoryRestConfiguration configuration) {
- if (this.basePath != null) {
- configuration.setBasePath(this.basePath);
- }
- if (this.defaultPageSize != null) {
- configuration.setDefaultPageSize(this.defaultPageSize);
- }
- if (this.maxPageSize != null) {
- configuration.setMaxPageSize(this.maxPageSize);
- }
- if (this.pageParamName != null) {
- configuration.setPageParamName(this.pageParamName);
- }
- if (this.limitParamName != null) {
- configuration.setLimitParamName(this.limitParamName);
- }
- if (this.sortParamName != null) {
- configuration.setSortParamName(this.sortParamName);
- }
- if (this.defaultMediaType != null) {
- configuration.setDefaultMediaType(this.defaultMediaType);
- }
- if (this.returnBodyOnCreate != null) {
- configuration.setReturnBodyOnCreate(this.returnBodyOnCreate);
- }
- if (this.returnBodyOnUpdate != null) {
- configuration.setReturnBodyOnUpdate(this.returnBodyOnUpdate);
- }
- if (this.enableEnumTranslation != null) {
- configuration.setEnableEnumTranslation(this.enableEnumTranslation);
- }
- }
-
public String getBasePath() {
return this.basePath;
}
@@ -193,4 +162,37 @@ public class RepositoryRestProperties {
this.enableEnumTranslation = enableEnumTranslation;
}
+ public void applyTo(RepositoryRestConfiguration configuration) {
+ if (this.basePath != null) {
+ configuration.setBasePath(this.basePath);
+ }
+ if (this.defaultPageSize != null) {
+ configuration.setDefaultPageSize(this.defaultPageSize);
+ }
+ if (this.maxPageSize != null) {
+ configuration.setMaxPageSize(this.maxPageSize);
+ }
+ if (this.pageParamName != null) {
+ configuration.setPageParamName(this.pageParamName);
+ }
+ if (this.limitParamName != null) {
+ configuration.setLimitParamName(this.limitParamName);
+ }
+ if (this.sortParamName != null) {
+ configuration.setSortParamName(this.sortParamName);
+ }
+ if (this.defaultMediaType != null) {
+ configuration.setDefaultMediaType(this.defaultMediaType);
+ }
+ if (this.returnBodyOnCreate != null) {
+ configuration.setReturnBodyOnCreate(this.returnBodyOnCreate);
+ }
+ if (this.returnBodyOnUpdate != null) {
+ configuration.setReturnBodyOnUpdate(this.returnBodyOnUpdate);
+ }
+ if (this.enableEnumTranslation != null) {
+ configuration.setEnableEnumTranslation(this.enableEnumTranslation);
+ }
+ }
+
}
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfigurationTests.java
index a0488ff3dda..2bf00dd0952 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfigurationTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/rest/RepositoryRestMvcAutoConfigurationTests.java
@@ -90,8 +90,7 @@ public class RepositoryRestMvcAutoConfigurationTests {
@Test
public void testWithCustomSettings() throws Exception {
- load(TestConfiguration.class,
- "spring.data.rest.default-page-size:42",
+ load(TestConfiguration.class, "spring.data.rest.default-page-size:42",
"spring.data.rest.max-page-size:78",
"spring.data.rest.page-param-name:_page",
"spring.data.rest.limit-param-name:_limit",
@@ -106,13 +105,18 @@ public class RepositoryRestMvcAutoConfigurationTests {
assertEquals("Custom default page size not set", 42, bean.getDefaultPageSize());
assertEquals("Custom max page size not set", 78, bean.getMaxPageSize());
assertEquals("Custom page param name not set", "_page", bean.getPageParamName());
- assertEquals("Custom limit param name not set", "_limit", bean.getLimitParamName());
+ assertEquals("Custom limit param name not set", "_limit",
+ bean.getLimitParamName());
assertEquals("Custom sort param name not set", "_sort", bean.getSortParamName());
assertEquals("Custom default media type not set",
- MediaType.parseMediaType("application/my-json"), bean.getDefaultMediaType());
- assertEquals("Custom return body on create flag not set", false, bean.returnBodyOnCreate(null));
- assertEquals("Custom return body on update flag not set", false, bean.returnBodyOnUpdate(null));
- assertEquals("Custom enable enum translation flag not set", true, bean.isEnableEnumTranslation());
+ MediaType.parseMediaType("application/my-json"),
+ bean.getDefaultMediaType());
+ assertEquals("Custom return body on create flag not set", false,
+ bean.returnBodyOnCreate(null));
+ assertEquals("Custom return body on update flag not set", false,
+ bean.returnBodyOnUpdate(null));
+ assertEquals("Custom enable enum translation flag not set", true,
+ bean.isEnableEnumTranslation());
}
@Test
diff --git a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java
index 3d96535f6dd..a7120b0ca9d 100644
--- a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java
+++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java
@@ -120,8 +120,7 @@ import org.springframework.web.context.support.StandardServletEnvironment;
* your application, however, any of the following sources can also be used:
*
*
- *
{@link Class} - A Java class to be loaded by {@link AnnotatedBeanDefinitionReader}
- *
+ *
{@link Class} - A Java class to be loaded by {@link AnnotatedBeanDefinitionReader}
*
*
{@link Resource} - An XML resource to be loaded by {@link XmlBeanDefinitionReader},
* or a groovy script to be loaded by {@link GroovyBeanDefinitionReader}
@@ -166,6 +165,15 @@ public class SpringApplication {
private static final Banner DEFAULT_BANNER = new SpringBootBanner();
+ private static final Set SERVLET_ENVIRONMENT_SOURCE_NAMES;
+ static {
+ Set names = new HashSet();
+ names.add(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME);
+ names.add(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME);
+ names.add(StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME);
+ SERVLET_ENVIRONMENT_SOURCE_NAMES = Collections.unmodifiableSet(names);
+ }
+
private final Log log = LogFactory.getLog(getClass());
private final Set