Java Ehcache在Spring 3.2中不工作

Java Ehcache在Spring 3.2中不工作,java,spring,ehcache,Java,Spring,Ehcache,这是我的实际做法 当我每秒刷新我的应用程序时,日期参数总是更新的 控制器 @Controller public class MainController implements ToCache { @RequestMapping(value = {"/", "/index"}) @Cacheable(value = "main", key = "#root.method.name") public String showHome(HttpServletRequest re

这是我的实际做法

当我每秒刷新我的应用程序时,日期参数总是更新的

控制器

@Controller
public class MainController implements ToCache {

    @RequestMapping(value = {"/", "/index"})
    @Cacheable(value = "main", key = "#root.method.name")
    public String showHome(HttpServletRequest request) {

        request.setAttribute("now", new Date());
        request.setAttribute("tmp", System.getProperty("java.io.tmpdir"));

        return "index";
    }

}
接口

public interface ToCache {

    String showHome(HttpServletRequest request);

}
Ehcache-servlet.xml

    <mvc:annotation-driven />

    <context:component-scan base-package="com.pjcom.**" />

    <!-- Manejador de vistas -->
    <bean id="viewResolver"
          class="org.springframework.web.servlet.view.InternalResourceViewResolver"
          p:prefix="/WEB-INF/view/"
          p:suffix=".jsp"
          p:exposeContextBeansAsAttributes="true" />

您可以发布spring配置的其余部分吗?在这个配置中应该缓存什么?您的可缓存方法的请求参数在每次调用时都将是新的-无需缓存…@geo而且我已经用所有配置更新了。@Dirk Lachowski,我不能缓存简单的html响应?我认为Dirk是正确的!您只需缓存showHome方法的调用,该方法始终是“索引”。SpringMVC然后使用它将处理卸载到视图处理程序,而您对此没有任何控制权。
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
    <property name="cacheManager" ref="ehcache"/>
</bean>

<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
    <property name="configLocation" value="classpath:ehcache.xml"/>
    <property name="shared" value="true"/>
</bean>

<bean id ="enhancedDefaultKeyGenerator" class="org.springframework.cache.interceptor.DefaultKeyGenerator"/>

<cache:annotation-driven mode="proxy" 
                         proxy-target-class="true" 
                         cache-manager="cacheManager" 
                         key-generator="enhancedDefaultKeyGenerator"/>

<!-- END EHCACHE -->
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" 
         updateCheck="true" 
         monitoring="autodetect" 
         dynamicConfig="true"
         maxBytesLocalHeap="150M">

    <diskStore path="java.io.tmpdir"/>    

    <cache name="main"
           maxBytesLocalHeap="100M"
           eternal="false"
           t

imeToIdleSeconds="10"
           timeToLiveSeconds="10"
           overflowToDisk="true"
           maxElementsOnDisk="1000"          
           memoryStoreEvictionPolicy="LRU"/>

</ehcache>
31-Mar-2014 21:33:20.881 INFO [http-nio-8084-exec-52] org.apache.catalina.startup.HostConfig.undeploy Repliegue (undeploy) de la aplicación web que tiene como trayectoria de contexto /springehcache
31-Mar-2014 21:33:20.917 INFO [http-nio-8084-exec-53] org.apache.catalina.startup.HostConfig.deployDescriptor Desplieque del descriptor de configuración C:\...\springehcache.xml
31-Mar-2014 21:33:20.919 WARNING [http-nio-8084-exec-53] org.apache.catalina.startup.SetContextPropertiesRule.begin [SetContextPropertiesRule]{Context} Setting property 'antiJARLocking' to 'true' did not find a matching property.
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
31-Mar-2014 21:33:22.843 INFO [http-nio-8084-exec-50] org.apache.catalina.util.LifecycleBase.start The start() method was called on component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/springehcache]] after start() had already been called. The second call will be ignored.