gpt4 book ai didi

caching - 如何在 Micronaut 的应用程序 YAML 中定义 Duration 对象

转载 作者:行者123 更新时间:2023-12-05 02:03:40 26 4
gpt4 key购买 nike

我正在尝试在 micronaut 中定义一个咖啡因缓存并通过应用程序 yaml 设置过期时间。

documentation表示

micronaut.caches.discovery-client.expire-after-write 应该定义为 Duration 对象,但不清楚如何在 YAML 中这样做。

---
micronaut:
application:
name: example-service
caches:
example-cache:
expire-after-write: 86400

出现以下错误:

Internal Server Error: Failed to inject value for parameter [expireAfterWrite] of method [setExpireAfterWrite] of class: io.micronaut.cache.caffeine.DefaultCacheConfiguration

Message: Error resolving property value [micronaut.caches.example-cache.expire-after-write]. Property doesn't exist
Path Taken: new $ExampleControllerDefinition$Intercepted(BeanContext beanContext,Qualifier qualifier,[Interceptor[] interceptors]) --> new CacheInterceptor([CacheManager cacheManager],CacheErrorHandler errorHandler,AsyncCacheErrorHandler asyncCacheErrorHandler,ExecutorService ioExecutor,BeanContext beanContext) --> new DefaultCacheManager([List caches],Provider dynamicCacheManager) --> new DefaultSyncCache([CacheConfiguration cacheConfiguration],ApplicationContext applicationContext,ConversionService conversionService) --> DefaultCacheConfiguration.setExpireAfterWrite([Duration expireAfterWrite])
io.micronaut.http.client.exceptions.HttpClientResponseException: Internal Server Error: Failed to inject value for parameter [expireAfterWrite] of method [setExpireAfterWrite] of class: io.micronaut.cache.caffeine.DefaultCacheConfiguration

大概是因为该值被视为 Integer 而不是 Duration

最佳答案

看起来你可以像这样简单地做到这一点:

---
micronaut:
application:
name: example-service
caches:
example-cache:
expire-after-write: 24h

关于caching - 如何在 Micronaut 的应用程序 YAML 中定义 Duration 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64989307/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com