Autowire一个 FactoryBean时,代码里要把变量的类型定义为FactoryBean.getObjectType()
以
<bean id="myCache" name="code"> //正确 @Autowired private Ehcache myCache; //因为 EhCacheFactoryBean.getObjectType() == Ehcache //错误: @Autowired private Cache myCache; //会报错,虽然Cache是Ehcache的子类。具体错误为“No unique bean of type [net.sf.ehcache.Cache] is defined”