【问题标题】:Getting SAXParseException when using task:annotation-driven tag in Spring MVC在 Spring MVC 中使用 task:annotation-driven tag 时出现 SAXParseException
【发布时间】:2015-01-03 09:53:42
【问题描述】:

我正在使用 Spring Framework 4.0.6 编写一个 Web 应用程序,我必须安排一个小例程来每天同时运行。 我正在尝试使用 @Scheduled 注释并在我的 dispatcher-servlet.xml 中添加 <task:annotation-driven /> 标记,但是当应用程序启动时我得到一个 SAXParseException 。 我的 xml 文件是这样的:

<?xml version='1.0' encoding='UTF-8' ?>
<!-- was: <?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:task="http://www.springframework.org/schema/task"
       xmlns:util="http://www.springframework.org/schema/util"
       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"
       xmlns:p="http://www.springframework.org/schema/p"
       xsi:schemaLocation="
            http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
            http://www.springframework.org/schema/task/     http://www.springframework.org/schema/task/spring-task-4.0.xsd
            http://www.springframework.org/schema/util/     http://www.springframework.org/schema/util/spring-util-4.0.xsd
            http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-4.0.xsd
            http://www.springframework.org/schema/mvc       http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
            http://www.springframework.org/schema/aop       http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
            http://www.springframework.org/schema/tx        http://www.springframework.org/schema/tx/spring-tx-4.0.xsd ">
    <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping"/>
    <bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"
          p:prefix="/WEB-INF/jsp/"
          p:suffix=".jsp" />
    <context:component-scan base-package="my.package.name.controllers" />
    <mvc:annotation-driven/>
    <task:annotation-driven />
</beans>

我得到的完整错误是:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 30 in XML document from ServletContext resource [/WEB-INF/spring-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 30; columnNumber: 30; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'task:annotation-driven'.

【问题讨论】:

    标签: java xml spring-mvc web saxparseexception


    【解决方案1】:

    解决了! 问题出在/ 字符中,位于http://www.springframework.org/schema/task/http://www.springframework.org/schema/util/ 的末尾。刚刚删除它们,就像在 http://www.springframework.org/schema/task 中一样,现在它工作得很好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-19
      • 2012-06-02
      • 2016-03-28
      • 2014-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多