【问题标题】:Cannot locate BeanDefinitionParser for element [resources]找不到元素的 BeanDefinitionParser [资源]
【发布时间】:2013-08-28 08:49:06
【问题描述】:

我最近将我的 Web 应用程序迁移到 Spring 3.2.3。 最近在尝试解决静态页面问题时,我遇到了 mvc:resources 命名空间。 但是,我在应用程序 context.xml 文件中遇到错误。 我已经搜索了很多但无法解决问题。请帮助。 我正在使用我的 Eclipse 8.6 和 Tomcat 6。

请注意,control+space 建议使用 mvc:resources.但我一使用它就会抛出 找不到元素 [资源] 的 BeanDefinitionParser

还尝试使用具有显式版本的架构。 我已经粘贴了相关代码

 <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:p="http://www.springframework.org/schema/p"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:mvc="http://www.springframework.org/schema/mvc" 
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:tx="http://www.springframework.org/schema/tx"

        xsi:schemaLocation="
                http://www.springframework.org/schema/beans 
                http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
                http://www.springframework.org/schema/context 
                http://www.springframework.org/schema/context/spring-context-3.2.xsd
                http://www.springframework.org/schema/mvc
                http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
                http://www.springframework.org/schema/aop 
                http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
                http://www.springframework.org/schema/tx 
                http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">

    <mvc:resources location="" mapping=""/>

</beans>

【问题讨论】:

    标签: spring spring-mvc xsd-validation


    【解决方案1】:

    确保您必须更正类路径中的 jar,确保 spring-webmvc.jar 在类路径中。使用 Maven(或 Gradle)时,请确保您的类路径中有该 jar 的单个(且正确)版本。多个版本可能会发生冲突。

    【讨论】:

    • 正确的 jars 在类路径中,我没有使用构建工具。
    • 判断你的类路径有什么不正确的异常。你从哪里得到异常?在 STS 中还是在部署中?
    • 在 applicationcontext.xml 文件中写入此命名空间后,我会立即在 Eclipse 中收到错误消息。
    • 你的意思是所有存在于 src?sry 中的 jar 用于询问
    • 没有 Eclipse 使用的实际类路径。 jar 文件位于文件系统的某个位置这一事实并不意味着 Eclipse 正在使用它。 (我强烈建议你开始使用MavenGradle 作为你的依赖项,为你省去很多痛苦和寻找罐子。)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-28
    相关资源
    最近更新 更多