以
<bean id="myCache" class="org.springframework.cache.ehcache.EhCacheFactoryBean"> 为例,
//正确 @Autowired private Ehcache myCache; //因为 EhCacheFactoryBean.getObjectType() == Ehcache //错误: @Autowired private Cache myCache; //会报错,虽然Cache是Ehcache的子类。具体错误为“No unique bean of type [net.sf.ehcache.Cache] is defined”