如何将togglz与spring-boot + jersey整合

时间:2016-03-30 09:54:33

标签: spring-boot jersey togglz

我的应用程序是Spring Boot + Jersey网络应用程序。我按照这个official tutorial将togglz与我的Spring Boot应用程序集成在一起。我将依赖项togglz-spring-boot-starter添加到了我的项目中。但是,在启动Spring Boot应用程序时,我始终会遇到缺少bean错误的问题。根据togglz spring-boot指南,它说这个依赖项应该将所有缺少的bean添加到应用程序中。我在这里缺少什么?

  

引起:org.springframework.beans.factory.UnsatisfiedDependencyException:在类路径资源中定义名称为'togglzEndpoint'的bean时出错[org / togglz / spring / boot / autoconfigure / TogglzAutoConfiguration $ TogglzEndpointConfiguration.class]:表示不满意的依赖关系通过类型为[org.togglz.core.manager.FeatureManager]的索引为0的构造函数参数::在类路径资源中定义名为'featureManager'的bean时出错[org / togglz / spring / boot / autoconfigure / TogglzAutoConfiguration $ FeatureManagerConfiguration.class ]:通过类型为[org.togglz.core.spi.FeatureProvider]的索引0的构造函数参数表示的不满意的依赖:::没有为依赖项找到类型[org.togglz.core.spi.FeatureProvider]的限定bean:预期至少为1 bean有资格作为此依赖项的autowire候选者。依赖注释:{};嵌套异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有为依赖项找到类型[org.togglz.core.spi.FeatureProvider]的限定bean:期望至少有一个bean可以作为此依赖项的autowire候选者。依赖注释:{};嵌套异常是org.springframework.beans.factory.UnsatisfiedDependencyException:在类路径资源中定义名为'featureManager'的bean时出错[org / togglz / spring / boot / autoconfigure / TogglzAutoConfiguration $ FeatureManagerConfiguration.class]:通过构造函数参数表示的不满意的依赖关系索引0的类型为[org.togglz.core.spi.FeatureProvider] ::没有找到类型[org.togglz.core.spi.FeatureProvider]的限定bean用于依赖:预期至少有1个bean有资格作为autowire候选者依赖。依赖注释:{};嵌套异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有为依赖项找到类型[org.togglz.core.spi.FeatureProvider]的限定bean:期望至少有一个bean可以作为此依赖项的autowire候选者。依赖注释:{}

     

由以下原因引起:org.springframework.beans.factory.NoSuchBeanDefinitionException:找不到类型为[org.togglz.core.spi.FeatureProvider]的限定bean用于依赖:预期至少有1个bean符合此依赖关系的autowire候选者。依赖注释:{}

1 个答案:

答案 0 :(得分:1)

最后我想出了问题,我必须在spring boot配置类中添加以下代码:

@Bean
public FeatureProvider featureProvider() {
    return new EnumBasedFeatureProvider(AppFeatures.class);
}