',spring,spring-boot,javabeans,autowired"/>

首页 > 解决方案 > NoSuchBeanDefinitionException:没有“java.util.function.Function”类型的限定 bean'

问题描述

    @Bean
    @ConditionalOnMissingBean
    fun storeCertificate(): Function<CacheData, Unit> {
        return Function { cacheAndData ->
//CacheAndData is a data class
            val (cache, key, cert, duration) = cacheAndData
            (cache.nativeCache as? RedisCacheWriter)
                    ?.run { put(CACHE_ISSUER_KEY, key.toByteArray(), ByteUtils.getBytes(cert), duration) }
                    ?: cache.put(key, cert)
        }
    }
}

在服务中自动装配私有 val storeCertificate:功能

在测试运行期间原因:org.springframework.beans.factory.NoSuchBeanDefinitionException:没有可用的“java.util.function.Function”类型的合格bean:预计至少有1个有资格作为自动装配候选者的bean。依赖注释:{}

标签: springspring-bootjavabeansautowired

解决方案


推荐阅读