现在,我正在观看由名为 Telusko
的 YouTube 频道发布的Spring MVC 教程
[0:09:11]
。上传于2019年6月14日,所以可能我遇到的错误是由于教程年代久远造成的。但也可能是这个事实与我的问题无关。
当我第一次按照视频中的描述创建一个
Maven
项目时,我选择apache-tomcat-8.0.53
(而不是8.0.2
(因为它不可用))作为我的Targeted Runtime
。
完成这些步骤后,我的
pom.xml
文件中仍然存在错误,显示 Could not initialize class org.apache.maven.plugin.war.util.WebappStructureSerializer
。 这个视频帮我解决了问题
在创建
telusko-servlet.xml
文件并使其看起来像这样之后......
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:ctx="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
<ctx:annotation-config></ctx:annotation-config>
<ctx:component-scan base-package="com.telusko"></ctx:component-scan>
</beans>
…我收到一条错误消息说
cvc-elt.1.a: Cannot find the declaration of element 'beans'.
.
怎么了?在本教程中,一切正常,但我无法从这里取得进展。我正在使用教程中描述的exact版本号everywhere.
这可能是由于 JDK 和 Eclipse 版本之间的兼容性问题..
也可能是因为maven插件太旧了..参考这个答案