问题描述
我只需要为spring.profiles.active = test的方法启用in_memory缓存。仅需要缓存最近10分钟内的请求。
现在,我将其设置如下:
@Profile("test")
@Configuration
class CachingConfig {
@Bean
fun cacheManager() = Caffeine.newBuilder()
.expireAfterWrite(10,TimeUnit.MINUTES)
.build<Any,Any>()
}
@Cacheable("request",key = "#dto.id")
fun request(dto: RequestDTO): Any {
...
}
@EnableCaching
@SpringBootApplication
@EnableConfigurationProperties
class Application
fun main(args: Array<String>) {
SpringApplication.run(Application::class.java,*args)
}
build.gragle
test {
systemProperty "spring.profiles.active","test"
}
但是我害怕将其扩展,因为我不确定它在那里是否可以正常工作。
我不完全了解:spring.profiles.active = prod怎么用?
- 如果未针对以下原因引发cacheManager bean,将发生错误: 产品?
- 在默认情况下,会不会发生在生产弹簧上提高cacheManager的情况?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)