0

EhCacheManagerFactoryBeanEhCacheFactoryBeanの javadoc を読んで、次のように考えました。

<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:configLocation="classpath:ehcache.xml"/>

<bean id="locationCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"
      p:cacheManager-ref="cacheManager"
      p:cacheName="locationCache"/>

@Autowired できるキャッシュを作成します。

クラス org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: ServletContext リソース [/WEB-INF/applicationContext.xml で定義された名前 'locationCache' を持つ Bean の作成中にエラーが発生しました]: init メソッドの呼び出しに失敗しました。ネストされた例外は java.lang.NoSuchMethodError: net.sf.ehcache.Cache.(Ljava/lang/String;ILnet/sf/ehcache/store/MemoryStoreEvictionPolicy; ZLjava/lang/String;ZJJZJLnet/sf/ehcache/event/RegisteredEventListeners; です。 Lnet/sf/ehcache/bootstrap/BootstrapCacheLoader;II)V

ehcache 1.7.2、1.6.2、および 1.5.0 を試しました。

<cache name="locationCache" />ehcache.xml で指定すると機能しますが、applicationContext.xml で構成を行うことを好みます。

<cache name="locationCache" /> 
4

1 に答える 1

3

欠落しているコンストラクターはEhcache1.3に属しており、新しいバージョンにはまだ存在しています。たぶん、あなたは依存関係にいくつかの問題を抱えています。Mavenを使用する場合はmvn dependency:tree -Dverbose=true、競合を探してみてください。

于 2010-01-14T00:49:39.317 に答える