Alberto de Blas
Alberto de Blas

Reputation: 58

Error executing Caffeine CacheBuilder configuration class when migrated to Kotlin

I am migrating to Kotlin CacheBuilder, a Spring Boot configuration class for CaffeineCache

@Configuration
@EnableCaching
open class CacheBuilder {
    @Bean
    open fun caffeineConfig(): Caffeine<Any, Transaction> {
        return CacheConfigurationHandler.transactionCaffeineConfig
    }

    @Bean
    open fun cacheManager(caffeine: Caffeine<Any, Any>): CacheManager {
        val caffeineCacheManager = CaffeineCacheManager("TransactionCache")
        caffeineCacheManager.setCaffeine(caffeine)
        return caffeineCacheManager
    }
}

when I run the application I get the error:

Parameter 0 of method cacheManager in com.initialization.CacheBuilder required a bean of type 'com.github.benmanes.caffeine.cache.Caffeine' that could not be found.

It is like the caffeineConfig method is not creating the Caffeine bean and Spring can not find it to pass to the cacheManager method.

Upvotes: 1

Views: 436

Answers (0)

Related Questions