Spring MVC 教程(作者 Telusko):“cvc-elt.1.a:找不到元素‘beans’的声明。”出现在“*-servlet.xml”文件中。怎么了?

问题描述 投票:0回答:1

现在,我正在观看由名为 Telusko

 的 YouTube 频道发布的 
Spring MVC 教程 [0:09:11]。上传于2019年6月14日,所以可能我遇到的错误是由于教程年代久远造成的。但也可能是这个事实与我的问题无关。

  1. 当我第一次按照视频中的描述创建一个

    Maven
    项目时,我选择
    apache-tomcat-8.0.53
    (而不是
    8.0.2
    (因为它不可用))作为我的
    Targeted Runtime

  2. 完成这些步骤后,我的

    pom.xml
    文件中仍然存在错误,显示
    Could not initialize class org.apache.maven.plugin.war.util.WebappStructureSerializer
    这个视频帮我解决了问题

  3. 在创建

    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.

java xml spring spring-mvc servlets
1个回答
0
投票

这可能是由于 JDK 和 Eclipse 版本之间的兼容性问题..

也可能是因为maven插件太旧了..参考这个答案

Could not initialize class org.apache.maven.plugin.war.util.WebappStructureSerializer -Maven 配置问题任何解决方案?

© www.soinside.com 2019 - 2024. All rights reserved.