找不到名为的缓存
Cannot find cache named
我正在尝试在我的应用程序中使用 gemfire 进行缓存。这是我的属性:
<context:component-scan base-package="my-base-package"/>
<context:annotation-config/>
<!-- Gemfire transation manager -->
<gfe:transaction-manager id="transactionManager" cache-ref="propertyGemfireCache"/>
<!-- Gemfire properties -->
<util:properties id="gemfire-props"
location="classpath:conf/environments/gemfire.properties"/>
<!-- Gemfire Client cache -->
<gfe:client-cache id="propertyGemfireCache" properties-ref="gemfire-props"
pool-name="gemfire-pool" pdx-serializer-ref="pdxSerializer" pdx-persistent="true"/>
<!-- Gemfire PDX serializer -->
<bean id="pdxSerializer" class="com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer">
<property name="serializableClasses">
<list>
<value>com\.acmecorp\.enterprise\.property\..*,java\.util\..*</value>
</list>
</property>
</bean>
<!-- Gemfire connection pool -->
<bean id="gemfire-pool" class="org.springframework.data.gemfire.client.PoolFactoryBean">
<property name="subscriptionEnabled" value="true"/>
<property name="freeConnectionTimeout" value="60000"/>
<property name="prSingleHopEnabled" value="true"/>
<property name="locators" ref="gemfireLocators"/>
</bean>
<bean id="gemfireCacheManager" class="org.springframework.data.gemfire.support.GemfireCacheManager"
p:cache-ref="propertyGemfireCache"/>
<gfe:client-region id="myRegion" name="${cache.region.name}" statistics="true"
cache-ref="propertyGemfireCache" shortcut="LOCAL">
<gfe:region-ttl timeout="86400"/>
</gfe:client-region>
<bean id="myTemplate" class="org.springframework.data.gemfire.GemfireTemplate">
<property name="region" ref="myRegion"/>
</bean>
<cache:advice id="myAdvice" cache-manager="gemfireCacheManager">
<cache:caching>
<cache:cacheable cache="myRegion" method="getSomeData"
key="''+#data"/>
</cache:caching>
</cache:advice>
<aop:config>
<aop:advisor advice-ref="myAdvice"
pointcut="execution( * *..ServiceImpl.getData(..)) and within(another-my-package.service.impl..*)"/>
</aop:config>
属性 cache.region.name
等于 correct_region_name
。
如果我 运行 我的应用程序,我将收到如下错误:
无法为 CacheableOperation[] 找到名为 'myRegion' 的缓存 caches=[myRegion]
但是如果我将 "myRegion" 替换为正确的区域,即 correct_region_name
。所以它看起来像这样:
<cache:cacheable cache="correct_region_name" method="getSomeData"
key="''+#data"/>
一切都会完美运行,但我不需要那个。有帮助吗?
我认为在客户端缓存配置中使用 属性 占位符 ${cache.region.name} 以及 Spring 解决这些问题的顺序可能存在问题。如果您在那里硬编码区域名称,它会起作用吗?
Spring(数据 GemFire) looks up the Cache
"name" in Spring's Cache Abstraction by the name of the Region (a.k.a. Cache
; which is not necessarily the bean ID, which is set here, since the RegionLookupFactoryBean
implements BeanNameAware).
你可以试试...
<cache:cacheable cache="${gemfire.region.name}" method="getSomeData" key="''+#data"/>
我正在尝试在我的应用程序中使用 gemfire 进行缓存。这是我的属性:
<context:component-scan base-package="my-base-package"/>
<context:annotation-config/>
<!-- Gemfire transation manager -->
<gfe:transaction-manager id="transactionManager" cache-ref="propertyGemfireCache"/>
<!-- Gemfire properties -->
<util:properties id="gemfire-props"
location="classpath:conf/environments/gemfire.properties"/>
<!-- Gemfire Client cache -->
<gfe:client-cache id="propertyGemfireCache" properties-ref="gemfire-props"
pool-name="gemfire-pool" pdx-serializer-ref="pdxSerializer" pdx-persistent="true"/>
<!-- Gemfire PDX serializer -->
<bean id="pdxSerializer" class="com.gemstone.gemfire.pdx.ReflectionBasedAutoSerializer">
<property name="serializableClasses">
<list>
<value>com\.acmecorp\.enterprise\.property\..*,java\.util\..*</value>
</list>
</property>
</bean>
<!-- Gemfire connection pool -->
<bean id="gemfire-pool" class="org.springframework.data.gemfire.client.PoolFactoryBean">
<property name="subscriptionEnabled" value="true"/>
<property name="freeConnectionTimeout" value="60000"/>
<property name="prSingleHopEnabled" value="true"/>
<property name="locators" ref="gemfireLocators"/>
</bean>
<bean id="gemfireCacheManager" class="org.springframework.data.gemfire.support.GemfireCacheManager"
p:cache-ref="propertyGemfireCache"/>
<gfe:client-region id="myRegion" name="${cache.region.name}" statistics="true"
cache-ref="propertyGemfireCache" shortcut="LOCAL">
<gfe:region-ttl timeout="86400"/>
</gfe:client-region>
<bean id="myTemplate" class="org.springframework.data.gemfire.GemfireTemplate">
<property name="region" ref="myRegion"/>
</bean>
<cache:advice id="myAdvice" cache-manager="gemfireCacheManager">
<cache:caching>
<cache:cacheable cache="myRegion" method="getSomeData"
key="''+#data"/>
</cache:caching>
</cache:advice>
<aop:config>
<aop:advisor advice-ref="myAdvice"
pointcut="execution( * *..ServiceImpl.getData(..)) and within(another-my-package.service.impl..*)"/>
</aop:config>
属性 cache.region.name
等于 correct_region_name
。
如果我 运行 我的应用程序,我将收到如下错误:
无法为 CacheableOperation[] 找到名为 'myRegion' 的缓存 caches=[myRegion]
但是如果我将 "myRegion" 替换为正确的区域,即 correct_region_name
。所以它看起来像这样:
<cache:cacheable cache="correct_region_name" method="getSomeData"
key="''+#data"/>
一切都会完美运行,但我不需要那个。有帮助吗?
我认为在客户端缓存配置中使用 属性 占位符 ${cache.region.name} 以及 Spring 解决这些问题的顺序可能存在问题。如果您在那里硬编码区域名称,它会起作用吗?
Spring(数据 GemFire) looks up the Cache
"name" in Spring's Cache Abstraction by the name of the Region (a.k.a. Cache
; which is not necessarily the bean ID, which is set here, since the RegionLookupFactoryBean
implements BeanNameAware).
你可以试试...
<cache:cacheable cache="${gemfire.region.name}" method="getSomeData" key="''+#data"/>