2016-09-27 97 views
1

我正在将应用程序从Jboss 4.2.2/java 6/Spring 2.5.4升级到Wildfly 9.0.2/java 8/Spring 4.3.2。迁移ehcache:代理弹簧4

Spring/Ehcache对其接口和工作流进行了很多更改,我无法找到任何有关为什么我的xml不再正确的信息。

我有一个问题声明:

<ehcache:proxy id="itemDaoCacheProxy" refId="itemDao"> 
    <ehcache:caching methodName="getAllItemNo" cacheName="itemTableCache" /> 
</ehcache:proxy> 

错误消息:

上下文初始化失败:org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:行98来自ServletContext资源的XML文档[/WEB-INF/spring-cfg.xml]无效;嵌套异常是org.xml.sax.SAXParseException; lineNumber:98; columnNumber:54; cvc-complex-type.2.4.c:匹配的通配符是严格的,但是对于元素'cache:proxy'没有声明。

我的XML声明如下所示:

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:aop="http://www.springframework.org/schema/aop" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:cache="http://www.springframework.org/schema/cache" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-4.3.xsd 
     http://www.springframework.org/schema/aop 
     http://www.springframework.org/schema/aop/spring-aop-4.3.xsd 
     http://www.springframework.org/schema/tx 
     http://www.springframework.org/schema/tx/spring-tx-4.3.xsd 
     http://www.springframework.org/schema/cache 
     http://www.springframework.org/schema/cache/spring-cache.xsd"> 

我使用的弹簧上下文support.jar为chache实用,但这个问题似乎被隔离到XML文件和架构。 “代理”元素似乎在后来的版本中已经分解了。

老:

https://github.com/zznate/spring-modules-ehcache/blob/master/src/main/java/org/springmodules/cache/config/ehcache/springmodules-ehcache.xsd

新:

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

什么exacly做的Ehcache:代理做的,我怎么能这个迁移到新标准?

最好的问候,

回答

1

这个帖子的细节方法我用迁移系统。

http://springtips.blogspot.se/2007/06/caching-methods-result-using-spring-and_23.html

<bean id="itemDaoCacheProxyMethodCache" class="org.springframework.aop.support.NameMatchMethodPointcutAdvisor"> 
    <property name="advice"> 
     <bean id="methodCacheInterceptor" class="com.myproject.mymodule.MethodCacheInterceptor"> 
      <property name="cache"> 
       <bean id="methodCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> 
        <property name="cacheManager"> 
         <ref bean="ehcache"/> 
        </property> 
        <property name="cacheName"> 
         <value>itemTableCache</value> 
        </property> 
       </bean> 
      </property> 
     </bean> 
    </property> 
    <property name="mappedName" value="getAllItemNo"/> 
</bean> 

<bean id="itemDaoCacheProxy" class="org.springframework.aop.framework.ProxyFactoryBean"> 
    <property name="target" ref="itemDao"/> 
    <property name="interceptorNames"> 
     <list> 
      <value>itemDaoCacheProxyMethodCache</value> 
     </list> 
    </property> 
</bean> 

什么代码所做的就是创建一个围绕我的类并实现对指定的函数缓存功能的新的容器。

这意味着可能有一些类的实例正在检查/更新缓存的响应,有些则不是。