EhCacheManagerFactoryBeanとEhCacheFactoryBeanの 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" />