SpringMVC 搭建遇到的坑

时间:2023-01-20 07:03:29

1. Caused by: org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 60; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.

多半是配置文件缺少链接找不到资源引起的,或是springmvc 版本和xsd版本不一致引起的.

idea新建的springMvc 工程,参考 https://blog.csdn.net/love_java_cc/article/details/76359815#commentBox

生成的配置文件,有

xmlns:context="http://www.springframework.org/schema/context"
我在下文中增加了
<context:component-scan base-package="com.spring.mvc"/>
就出错了,还需要还需要添加 URL
在dispatchcher-sevlet.xml 中增加
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
就能运行成功.