报错信息
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Cannot locate BeanDefinitionDecorator for element [annotation-driven]
Offending resource: class path resource [springmvc.xml]
当该错误出现的时候,是我的springmvc.xml中
<!--开启springmvc框架注解的支持 -->
<mvc:annotation-driven/>
的这个配置位置写在了<bean>中了,如果你们也有这样的错误的话,希望能对你有帮助
改正后的代码
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!--配置扫描路径-->
<context:component-scan base-package="com.itcast"/>
<!--视图解析器对象-->
<bean id="internalResourceViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!--配置视图所在的路径-->
<property name="prefix" value="/WEB-INF/pages/"/>
<!--配置视图文件的后缀名-->
<property name="suffix" value=".jsp"/>
</bean>
<!--开启springmvc框架注解的支持 -->
<mvc:annotation-driven/>
</beans>
关于这个配置文件错误的报错,很好的解决办法就是仔细分析一下你的配置文件结构,因为这个很容易会被忽略的