我有一个用于设置 gemfire 的 xml 配置文件,如下所示
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gfe="http://www.springframework.org/schema/gemfire"
xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan
base-package="com.mycompany.data.testcache" />
<context:annotation-config />
<util:properties id="props" location="classpath:test-cache.properties">
<prop key="log-level">info</prop>
</util:properties>
<gfe:cache id="gemfire-cache" properties-ref="props" />
<gfe:local-region id="region1">
<gfe:cache-listener ref="listener" />
</gfe:local-region>
<bean id="listener"
class="com.mycompany.data.TestLoggingCacheListener" />
</beans>
当我尝试加载此配置文件时,我看到以下异常..
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 原因:org.springframework.beans.factory.BeanCreationException:创建名为“region1”的bean时出错:无法解析对bean的引用gemfireCache' 同时设置 bean 属性'cache';嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'gemfireCache' is defined at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) at org.springframework.beans.factory .support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106) 在 org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory。
org.springframework.beans.factory.NoSuchBeanDefinitionException:在 org.springframework.beans.factory.support 的 org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:529) 中没有定义名为“gemfireCache”的 bean。 AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1095) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:277) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java: 193) 在 org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322) ... 41 更多
当我从中删除 id 属性时
<gfe:cache id="gemfire-cache" properties-ref="props" />
然后给
<gfe:cache properties-ref="props" />
它工作正常。当我指定 id 属性时,它会抛出 t 任何人都可以帮助我吗