小编Roa*_*ner的帖子

什么是对象发布?为什么我们需要它?

在我为Java Developer进行的一次面试中,我被问到一个问题:

什么是对象发布?为什么我们需要它?

我不确定我知道正确的答案:

我认为对象发布是指将对象(变量)状态放入堆内存时.并且它需要线程之间共享的对象(变量).

我对吗?如果我错了,请纠正我.我一直在搜索Java语言规范,但没有发现任何能明确回答这个问题的内容.

提示:这个问题是故意以非严格和严格的方式形成的 - 这就是它的关键.

java

14
推荐指数
1
解决办法
2391
查看次数

Spring3.1和hibernate4 + eh-cache

我在我的Web应用程序中使用Spring3.1hibernate4.在这里,我正在尝试eh缓存,但得到一些错误,这是我使用的配置: -

调度员servlet.xml中

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:cache="http://www.springframework.org/schema/cache"
    http://www.springframework.org/schema/cache
    http://www.springframework.org/schema/cache/spring-cache-3.1.xsd">

    <cache:annotation-driven />
    <bean id="defaultEhCacheManager"
        class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean"
        p:config-location="/WEB-INF/ehcache.xml" p:shared="false"></bean>
    <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
        <property name="cacheManager" ref="ehcache"></property>
    </bean>
    <cache:annotation-driven cache-manager="cacheManager" />
    <bean id="cacheManager">
        <property name="cacheManager" ref="ehcache" />
    </bean>
    <bean id="ehcache"
        class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
        <property name="configLocation" value="/WEB-INF/ehcache.xml" />
    </bean> 
Run Code Online (Sandbox Code Playgroud)

ehcache.xml中

<cache name="sampleCache1" 
    maxElementsInMemory="10000"
    eternal="false"
    overflowToDisk="true"
    timeToIdleSeconds="300"
    timeToLiveSeconds="600">
</cache>
Run Code Online (Sandbox Code Playgroud)

这是依赖: -

<dependency>
    <groupId>net.sf.ehcache</groupId>
    <artifactId>ehcache-core</artifactId>
    <version>2.5.2</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

我收到以下错误: -

重度:上下文初始化失败org.springframework.beans.factory.BeanCreationException:错误创建名称为豆"org.springframework.cache.interceptor.CacheInterceptor#0":无法解析参考豆"的CacheManager"而设置的bean属性"的CacheManager"; 嵌套的例外是org.springframework.beans.factory.BeanCreationException:错误创建名称为豆"的CacheManager"在ServletContext的资源定义[/WEB-INF/dispatcher-servlet.xml]:无法解析参考豆"的Ehcache"而设置的bean属性'的CacheManager'; 嵌套的例外是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有名为"的Ehcache"豆是指在确定

请尽快建议任何解决方案.

提前致谢

spring hibernate ehcache

1
推荐指数
1
解决办法
4583
查看次数

标签 统计

ehcache ×1

hibernate ×1

java ×1

spring ×1