下面是我的缓存的实例化方式:
return Caffeine.newBuilder()
.maximumSize(10)
.expireAfterWrite(15, TimeUnit.MINUTES)
.build()如何配置Spring来执行依赖注入?
<bean id="matchedDFUCache" class="com.github.benmanes.caffeine.cache.Caffeine" factory-method="newBuilder"></bean>给了我这个错误:
[coral:launch] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'realTimeForecastFactory': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'matchedDFUCache' is expected to be of type 'com.github.benmanes.caffeine.cache.Cache' but was actually of type 'com.github.benmanes.caffeine.cache.Caffeine'发布于 2020-08-12 03:12:11
<bean id="caffeineBuilder" class="com.github.benmanes.caffeine.cache.Caffeine" factory-method="newBuilder">
</bean>
<bean id="matchedDFUCache" factory-bean="caffeineBuilder" factory-method="build">
</bean>https://stackoverflow.com/questions/63364752
复制相似问题