【问题标题】:Cannot find Region in cache GemFireCache在缓存 GemFireCache 中找不到区域
【发布时间】:2017-01-23 17:02:19
【问题描述】:
Caused by: org.springframework.beans.factory.BeanInitializationException: Cannot find region [record] in cache GemFireCache[id = 20255495; 
isClosing = false; isShutDownAll = false;
 closingGatewayHubsByShutdownAll = false; created = Mon Jan 23 11:45:10 EST 2017; server = false; copyOnRead = false; lockLease = 120; lockTimeout = 60]
    at org.springframework.data.gemfire.RegionLookupFactoryBean.lookupFallback(RegionLookupFactoryBean.java:72)
    at org.springframework.data.gemfire.RegionLookupFactoryBean.afterPropertiesSet(RegionLookupFactoryBean.java:59)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1541)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1479)
    ... 13 more

我的 XML 文件是:

<beans>

    ....

    <context:component-scan base-package="spring.gemfire.repository.deptemp"/>

    <gfe:client-cache id="gemfireCache" pool-name="gfPool"/>

    <!--Region for being used by the Record Bean -->
    <gfe:replicated-region id="record" cache-ref="gemfireCache"/>

    <bean id="record" class="spring.gemfire.repository.deptemp.beans.Record"/>

    <gfe:pool id="gfPool" max-connections="10" subscription-enabled="true" >  
        <gfe:locator host="localhost" port="10334"/>        
    </gfe:pool>   

    <gfe:lookup-region id="record" />  
    <gfe-data:repositories base-package="spring.gemfire.repository.deptemp.repos"/>  

</beans>

【问题讨论】:

    标签: gemfile spring-data-gemfire


    【解决方案1】:

    阿布谢赫-

    为什么你有这两个...

    <gfe:replicated-region id="record" cache-ref="gemfireCache"/>
    

    还有这个……

    <gfe:lookup-region id="record" />
    

    另外,你已经定义了这个...

    <bean id="record" class="spring.gemfire.repository.deptemp.beans.Record"/>
    

    根据上面定义的 XML 中 bean 定义的“顺序”,哪个(最肯定)覆盖了您的 REPLICATE Region bean 定义(也使用 id="record")。

    虽然 Spring 首先遵循 bean 定义之间的依赖顺序,但当不存在依赖关系(显式或隐式)时,它通常会遵循声明的顺序。

    由于&lt;bean id="record" .../&gt;&lt;gfe:replicated-region id="record" ../&gt; 之后,所以&lt;bean id=record../&gt; 会覆盖&lt;gfe:replicated-region id="record"/&gt; bean 定义。

    此外,不需要&lt;gfe:lookup-region&gt;,因为您没有使用 GemFire/Geode 的本机配置(例如 cache.xml)或集群配置服务

    此外,您要声明 ClientCache,所以从技术上讲,您可能希望 &lt;gfe:client-region&gt; 与 GemFire/Geode 服务器区域匹配,是吗?!

    虽然您可以在客户端上创建 REPLICATE 区域(甚至是 PARTITION 区域),但您通常不会这样做,因为这些区域不是任何分布式系统或 GemFire“服务器”节点集群的一部分。

    客户端区域(可以是 PROXY,甚至是 CACHING_PROXY)会将数据操作分发到服务器。此外,如果您有只有特定客户需要的数据,那么您应该使用&lt;gfe:local-region&gt; 创建本地区域。

    我肯定会首先阅读这个......

    http://gemfire.docs.pivotal.io/geode/basic_config/book_intro.html

    接下来是这个……

    http://gemfire.docs.pivotal.io/geode/topologies_and_comm/book_intro.html

    那么这个……

    http://gemfire.docs.pivotal.io/geode/developing/book_intro.html

    最后...

    http://docs.spring.io/spring-data-gemfire/docs/current/reference/html/#bootstrap

    -约翰

    【讨论】:

    • 嘿约翰 - 感谢您的意见。
    • 更新了 cache.xml 文件,现在它没有给出错误。
    • 我正在使用 CRUDRepository。 public interface RecordRepository extends CrudRepository{ } 但是,在我执行下面的代码 RecordRepository recRepos = ctx.getBean(RecordRepository.class); Record rec1 = new Record(100L,"1","第一条记录");
    • 在 Eclipse 控制台中,它显示好像正在插入记录。 100 1 第一条记录 但是,该记录没有被插入到区域中。
    • query --query="select * from /record" 在 gfsh 中不返回任何结果
    猜你喜欢
    • 2014-05-25
    • 2013-10-09
    • 2019-05-13
    • 2015-02-26
    • 1970-01-01
    • 1970-01-01
    • 2011-02-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多