Skip to content

Commit 4fd368b

Browse files
committed
Deprecate mvc XML configuration namespace
This commit deprecates the `<mvc:*` XML configuration namespace for configuring Spring MVC applications. This configuration model is lagging behind in the 6.x generation already and we don't intend to invest in this space to close that gap. As of 7.0, using this XML namespace will result in a WARN log message. This commit also states our intent in the reference documentation. Closes gh-34063
1 parent f094c46 commit 4fd368b

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

framework-docs/modules/ROOT/pages/web/webmvc/mvc-config/enable.adoc

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ You can use the `@EnableWebMvc` annotation to enable MVC configuration with prog
77

88
include-code::./WebConfiguration[tag=snippet,indent=0]
99

10+
WARNING: As of 7.0, support for the XML configuration namespace for Spring MVC has been deprecated.
11+
There are no plans yet for removing it completely but XML configuration will not be updated to follow
12+
the Java configuration model.
13+
1014
NOTE: When using Spring Boot, you may want to use `@Configuration` classes of type `WebMvcConfigurer` but without `@EnableWebMvc` to keep Spring Boot MVC customizations. See more details in xref:web/webmvc/mvc-config/customize.adoc[the MVC Config API section] and in {spring-boot-docs-ref}/web/servlet.html#web.servlet.spring-mvc.auto-configuration[the dedicated Spring Boot documentation].
1115

1216
The preceding example registers a number of Spring MVC

spring-webmvc/src/main/java/org/springframework/web/servlet/config/MvcNamespaceHandler.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2021 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,9 @@
1616

1717
package org.springframework.web.servlet.config;
1818

19+
import org.apache.commons.logging.Log;
20+
import org.apache.commons.logging.LogFactory;
21+
1922
import org.springframework.beans.factory.xml.NamespaceHandler;
2023
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
2124

@@ -29,8 +32,11 @@
2932
*/
3033
public class MvcNamespaceHandler extends NamespaceHandlerSupport {
3134

35+
private static final Log logger = LogFactory.getLog(MvcNamespaceHandler.class);
36+
3237
@Override
3338
public void init() {
39+
logger.warn("The XML configuration namespace for Spring MVC is deprecated, please use Java configuration instead.");
3440
registerBeanDefinitionParser("annotation-driven", new AnnotationDrivenBeanDefinitionParser());
3541
registerBeanDefinitionParser("default-servlet-handler", new DefaultServletHandlerBeanDefinitionParser());
3642
registerBeanDefinitionParser("interceptors", new InterceptorsBeanDefinitionParser());

0 commit comments

Comments
 (0)