gpt4 book ai didi

java - 使用任务 :annotation-driven tag in Spring MVC 时出现 SAXParseException

转载 作者:太空宇宙 更新时间:2023-11-04 06:26:04 31 4
gpt4 key购买 nike

我正在使用 Spring Framework 4.0.6 编写一个 Web 应用程序,我必须安排一个小例程每天同时运行。我正在尝试使用 @Scheduled注释并添加 <task:annotation-driven />我的 Dispatcher-servlet.xml 中的标记,但我得到 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'.

最佳答案

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

关于java - 使用任务 :annotation-driven tag in Spring MVC 时出现 SAXParseException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26787140/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com