gpt4 book ai didi

java - Togglz Spring Boot - 未提供功能管理器

转载 作者:行者123 更新时间:2023-11-30 06:52:44 26 4
gpt4 key购买 nike

我尝试将 togglz 集成到我的 Spring Boot 应用程序中,但是看起来自动配置很难提供 FeatureManager。以下是我的堆栈跟踪:

2017-02-23 16:04:30.033 DEBUG [myService,,,] 23359 --- [  restartedMain] org.togglz.core.context.FeatureContext   : No cached FeatureManager for class loader: org.springframework.boot.devtools.restart.classloader.RestartClassLoader@6b8005f1
2017-02-23 16:05:57.403 DEBUG [myService,,,] 23359 --- [ restartedMain] org.togglz.core.context.FeatureContext : Found 5 FeatureManagerProvider implementations...
2017-02-23 16:06:27.652 DEBUG [myService,,,] 23359 --- [ restartedMain] org.togglz.core.context.FeatureContext : No FeatureManager provided by org.togglz.core.context.ThreadLocalFeatureManagerProvider
2017-02-23 16:06:36.436 DEBUG [myService,,,] 23359 --- [ restartedMain] org.togglz.core.context.FeatureContext : No FeatureManager provided by org.togglz.core.context.BeanFinderFeatureManagerProvider
2017-02-23 16:06:45.980 DEBUG [myService,,,] 23359 --- [ restartedMain] org.togglz.core.context.FeatureContext : No FeatureManager provided by org.togglz.core.context.StaticFeatureManagerProvider
2017-02-23 16:06:51.164 DEBUG [myService,,,] 23359 --- [ restartedMain] org.togglz.core.context.FeatureContext : No FeatureManager provided by org.togglz.core.context.ContextClassLoaderFeatureManagerProvider
2017-02-23 16:06:55.980 DEBUG [myService,,,] 23359 --- [ restartedMain] o.t.c.c.JNDIFeatureManagerProvider : FeatureMananger not found: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
2017-02-23 16:06:57.990 DEBUG [myService,,,] 23359 --- [ restartedMain] org.togglz.core.context.FeatureContext : No FeatureManager provided by org.togglz.core.context.JNDIFeatureManagerProvider

应用程序最终因 IllegalStateException 而死亡:

Caused by: java.lang.IllegalStateException: Could not find the FeatureManager. For web applications please verify that the TogglzFilter starts up correctly. In other deployment scenarios you will typically have to implement a FeatureManagerProvider as described in the 'Advanced Configuration' chapter of the documentation.
at org.togglz.core.context.FeatureContext.getFeatureManager(FeatureContext.java:53) ~[togglz-core-2.3.0.Final.jar:na]

我在我的应用程序属性中定义了 togglz.enabled 和我的 togglz.feature-enums 属性,以及创建的实现 TogglzConfig 的配置类,看起来无论 Spring Boot 使用 togglz 在幕后做什么,都不太有效。有其他人遇到过这个问题或知道如何解决吗?

最佳答案

首先,我建议您更新您的帖子以包括:

  • Spring 启动配置
  • 最小特征枚举
  • pom.xml

请注意,如果您使用的是 Spring Boot,则应使用以下 GAV:

<dependency>
<groupId>org.togglz</groupId>
<artifactId>togglz-spring-boot-starter</artifactId>
<version>2.4.1.Final</version>
</dependency>
<dependency>
<groupId>org.togglz</groupId>
<artifactId>togglz-console</artifactId>
<version>2.4.1.Final</version>
</dependency>

那么它应该像定义返回的 bean 一样简单:

  • 状态存储库
  • 功能提供者
  • 用户提供者

一个简单的实现是:

@Bean
public StateRepository getStateRepository() {
return new InMemoryStateRepository()
}

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

@Bean
public UserProvider getUserProvider() {
return new NoOpUserProvider();
}

其中MyFeatures.class是实现Feature的枚举

为 Spring Boot 设置的其他可能有益的属性包括:

togglz.console.enabled=true
togglz.console.secured=false

关于java - Togglz Spring Boot - 未提供功能管理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42421315/

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