2011-03-07 71 views
1

我想使用Spring Cache features,但我不知道此模塊具有哪些依賴關係。我有這樣的配置:使用Spring Cache的依賴關係

<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 /> 

<cache:annotation-driven />沒有被認可。它給出了這樣的錯誤:

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的工作?或彈性體我在哪裏可以找到這些信息?

感謝

回答

6

您還需要:

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

和正確的XSD是:

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

我已經又增加了它春瓶,雖然我還沒有包括在我的問題。必須有更多的東西丟失(我認爲它可能是一個jar文件) – Javi 2011-03-07 14:11:35

+0

@Javi看到更新 – Bozho 2011-03-07 14:13:08

+0

謝謝,錯誤停止。 http://static.springsource.org/spring/docs/3.1.0.M1/spring-framework-reference/html/cache.html中的文檔說我有xsd,所以我認爲它是錯誤的。還有一個問題。我應該將mvc xsd從spring-mvc-3.0.xsd更改爲spring-mvc-3.1.xsd(因爲文檔中還提到了spring-mvc-3.0.xsd)? – Javi 2011-03-07 15:25:51

0

你明白這個功能是春天3.1,這是沒有公佈的一部分是?

所以,你需要使用從milestone build of Spring 3.1.

+0

我已經在使用那個里程碑版本的jar了 – Javi 2011-03-07 15:16:03

+0

@Javi:運行一個程序或IDE時是否遇到這個錯誤? – axtavt 2011-03-07 15:25:34

+0

在IDE中,我認爲Bozho答案是正確的,雖然由於另一個錯誤我沒有檢查它 – Javi 2011-03-07 15:27:40