java-Spring ehcache没有这样的方法错误

Caused by: java.lang.NoSuchMethodError: org.springframework.cache.ehcache.EhCach
eFactoryBean.setMaxEntriesLocalHeap(J)V


    Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cache.ehcache.EhCacheFactoryBean]:
     Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework
    .cache.ehcache.EhCacheFactoryBean.setMaxEntriesLocalHeap(J)V
            at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
            at org.springframework.beans.factory.support.SimpleInstantiationStrategy
    .instantiate(SimpleInstantiationStrategy.java:89)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBean
    Factory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1086)
            ... 192 more
    Caused by: java.lang.NoSuchMethodError: org.springframework.cache.ehcache.EhCach
    eFactoryBean.setMaxEntriesLocalHeap(J)V
            at org.springframework.cache.ehcache.EhCacheFactoryBean.<init>(EhCacheFa
    ctoryBean.java:101)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
    orAccessorImpl.java:62)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
    onstructorAccessorImpl.java:45)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
            at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:1
    47)
            ... 194 more

解决方法:

错误似乎很明显

您使用的Version 2.5没有方法.

EhCacheFactoryBean的Version 4.1似乎具有该方法.

我猜您混合了不兼容的jar版本.

上一篇:Ehcache与Hibernate和Spring的集成异常:二级缓存未启用使用


下一篇:java-timetoliveseconds ehcache春季启动配置不起作用