Java 将ehcache:proxy迁移到spring 4
我正在将一个应用程序从JBoss4.2.2/Java6/Spring2.5.4升级到Wildfly 9.0.2/Java8/Spring4.3.2 Spring/Ehcache对它们的接口和工作流程做了很多更改,我找不到任何关于我的xml不再正确的原因的信息 我对以下声明有疑问:Java 将ehcache:proxy迁移到spring 4,java,spring,xsd,ehcache,xsd-validation,Java,Spring,Xsd,Ehcache,Xsd Validation,我正在将一个应用程序从JBoss4.2.2/Java6/Spring2.5.4升级到Wildfly 9.0.2/Java8/Spring4.3.2 Spring/Ehcache对它们的接口和工作流程做了很多更改,我找不到任何关于我的xml不再正确的原因的信息 我对以下声明有疑问: <ehcache:proxy id="itemDaoCacheProxy" refId="itemDao"> <ehcache:caching methodName="getAllItemNo
<ehcache:proxy id="itemDaoCacheProxy" refId="itemDao">
<ehcache:caching methodName="getAllItemNo" cacheName="itemTableCache" />
</ehcache:proxy>
错误消息:
上下文初始化失败:org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:来自ServletContext资源[/WEB-INF/spring cfg.xml]的xml文档中的第98行无效;嵌套异常为org.xml.sax.saxpasseeption;行号:98;栏目号:54;cvc复杂类型.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">
我将spring-context-support.jar用于chache实用程序,但问题似乎与xml文件和模式无关。“代理”元素似乎已在以后的版本中消失
旧的:
新的:
ehcache:proxy具体做什么?如何将其迁移到新标准
致以最诚挚的问候,这篇文章详细介绍了我用来迁移系统的方法
itemTableCache
itemDaoCacheProxyMethodCache
代码所做的是创建一个新的容器来包装我的类,并为指定的函数实现缓存功能
这意味着类中可能存在一些实例,其中一些正在检查/更新缓存响应,而另一些则没有
<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>