【问题标题】:Dependencies for using Spring Cache使用 Spring Cache 的依赖项
【发布时间】:2011-07-10 09:07:15
【问题描述】:

我想使用Spring Cache features,但我不知道这个模块有什么依赖关系。我有这样的配置:

<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.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.xsd
    http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">

    ...

<mvc:annotation-driven />
<cache:annotation-driven />

&lt;cache:annotation-driven /&gt; 未被识别。它给出了这个错误:

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'cache:annotation-driven'

我认为是因为我没有添加所有Spring模块的jar文件(我在真正需要它们时添加它们)。

让 Spring Cache 工作需要哪些 spring 模块 jar?或者最后我在哪里可以找到这些信息?

谢谢

【问题讨论】:

    标签: java spring caching dependencies spring-3


    【解决方案1】:

    你知道这个功能是 Spring 3.1 的一部分,没有发布是吗?

    所以,你需要使用来自milestone build of Spring 3.1.的Spring jars

    【讨论】:

    • @Javi:您在运行程序时或在 IDE 中是否收到该错误?
    • 在 IDE 中,我认为 Bozho 的答案是正确的,尽管由于另一个错误我根本没有检查它
    【解决方案2】:

    你还需要:

    xmlns:cache="http://www.springframework.org/schema/cache"
    

    正确的xsd是:

    http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
    

    【讨论】:

    • 我已经添加了它,尽管我没有将它包含在我的问题中。肯定还少了点什么(我觉得可能是jar文件)
    • 感谢错误停止。 static.springsource.org/spring/docs/3.1.0.M1/… 中的文档说我有 xsd,所以我认为它是错误的。只是另一个问题。我应该将 mvc xsd 从 spring-mvc-3.0.xsd 更改为 spring-mvc-3.1.xsd(因为文档还说 spring-mvc-3.0.xsd)?
    • 其实两个XSD都是正确的,但是这个是可以下载的,这样IDE就可以验证了。
    猜你喜欢
    • 2021-10-25
    • 1970-01-01
    • 2019-08-19
    • 1970-01-01
    • 2011-10-07
    • 2018-04-13
    • 1970-01-01
    • 2018-01-22
    • 2011-01-18
    相关资源
    最近更新 更多