问题描述:
构建一个spring的dubbo项目,在本地eclipse是正常的,但是在服务器上启动总是报错,错误信息如下
The matching wildcard is strict, but no declaration can be found for element 'task:annotation-driven'.
问题排除步骤:
1 检查是否配置 xmlns和schemaLocation:
xmlns:tx="http://www.springframework.org/schema/task"
主要不要写成 xmlns:task="http://www.springframework.org/task/spring-task"
xsi:schemaLocation="http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.3.xsd“
2 检查是否配置扫描器(主要是避免task是否生效问题):
<context:component-scan base-package="com.*" />
3 检查是否有配置文件spring-task-4.3.xsd(我遇到的问题)
这里直接用浏览器打开,会发现网络上是存在这个文件的,但是服务器上是不能连接网络的,只能访问jar包里的配置文件,如果jar包里没有这个文件,也就是会出现错误(我遇到的情况):
The matching wildcard is strict, but no declaration can be found for element 'task:annotation-driven'.
jar包查看spring-task-4.3.xsd文件方法:
① 找到spring-context-4.2.5.RELEASE.jar,打开jar(可以用解压软件),直接可以看到spring.schemas文件。
② 打开spring.schemas,收缩spring-task,可以找到对应的spring-task文件路径
③ 查看是否有spring-task-4.3.xsd文件,并在对应的路径下确认下文件,如果没有,这改成spring-task-4.2.xsd,或者其他有的版本,同时确保服务器的服务上有spring-context的包。
如上则 是这次问题的解决步骤(欢迎指正)