Avoid registering a SpringDataWebSettings bean by default.
We now refrain from registering a SpringDataWebSettings instance as bean in the ApplicationContext if @EnableSpringDataWebSupport is used without an explicit declaration of pageSerializationMode. This allows Spring Boot to use the annotation, but allow the attribute value to be configured via a property at the same time. See https://github.com/spring-projects/spring-boot/pull/39797#discussion_r1508396169 for details. Fixes GH-3054.
This commit is contained in:
committed by
Oliver Drotbohm
parent
e994f6b60f
commit
e074fcc2dd
@@ -69,6 +69,7 @@ import org.springframework.util.ClassUtils;
|
||||
* @see SpringDataWebConfiguration
|
||||
* @see HateoasAwareSpringDataWebConfiguration
|
||||
* @author Oliver Gierke
|
||||
* @author Yanming Zhou
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ ElementType.TYPE, ElementType.ANNOTATION_TYPE })
|
||||
@@ -170,6 +171,7 @@ public @interface EnableSpringDataWebSupport {
|
||||
* {@link EnableSpringDataWebSupport}.
|
||||
*
|
||||
* @author Oliver Drotbohm
|
||||
* @author Yanming Zhou
|
||||
* @soundtrack Norah Jones - Chasing Pirates
|
||||
* @since 3.3
|
||||
*/
|
||||
@@ -190,8 +192,14 @@ public @interface EnableSpringDataWebSupport {
|
||||
return;
|
||||
}
|
||||
|
||||
Object pageSerializationMode = attributes.get("pageSerializationMode");
|
||||
|
||||
if (pageSerializationMode == PageSerializationMode.DIRECT) {
|
||||
return;
|
||||
}
|
||||
|
||||
AbstractBeanDefinition definition = BeanDefinitionBuilder.rootBeanDefinition(SpringDataWebSettings.class)
|
||||
.addConstructorArgValue(attributes.get("pageSerializationMode"))
|
||||
.addConstructorArgValue(pageSerializationMode)
|
||||
.getBeanDefinition();
|
||||
|
||||
String beanName = importBeanNameGenerator.generateBeanName(definition, registry);
|
||||
|
||||
Reference in New Issue
Block a user