4

我的 spring-boot+jersey 应用程序集成了 togglz。我添加了以下依赖项,如下所示。

// togglz
compile('org.togglz:togglz-servlet:'+togglzVersion)
compile('org.togglz:togglz-cdi:'+togglzVersion)
compile('javax.enterprise:cdi-api:2.0-EDR1')
compile('org.togglz:togglz-spring-web:'+togglzVersion)
compile("org.togglz:togglz-spring-boot-starter:"+togglzVersion)
compile("org.togglz:togglz-console:"+togglzVersion)
compile("org.togglz:togglz-spring-security:"+togglzVersion)
compile("com.github.heneke.thymeleaf:thymeleaf-extras-togglz:1.0.1.RELEASE")

在我的引导类中,我添加了以下代码:

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

启动应用程序后,我可以从这个链接看到 json 数据:http://localhost:8080/togglz。但我无法访问http://localhost:8080/togglz-console。我收到“加载资源失败:服务器响应状态为 403(禁止)”错误。

我可以在我的日志文件中看到下面的日志,但我无法访问 togglz-console/*.

o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'togglzConsoleServlet' to [/togglz-console/*]

下面是我的 togglz 属性文件:

# togglz
togglz:
    feature-enums: com.cooltoo.backend.features.AppFeatures # Comma-separated list of fully-qualified feature enum class names.
    features:
        SMS_CODE: false
    console:
        enabled: true # Enable admin console.
        path: /togglz-console # The path of the admin console when enabled.

我在这里错过了什么?

4

2 回答 2

4

Step1添加以下依赖:

   <!-- Togglz Admin Console -->
    <dependency>
       <groupId>org.togglz</groupId>
       <artifactId>togglz-console</artifactId>
       <version>2.3.0.RC1</version>
   </dependency>

Step2在您的 application.yml 或 application.properties 中添加以下内容

togglz:
  console:
    enabled: true # Enable admin console.

或者

togglz.console.enabled: true # Enable admin console.

Step3配置控制台路径

togglz:
    console:
     path: /togglz-console # The path of the admin console when enabled.

For authentication : Add a dummy UserProvider which assigns admin privileges to every user:

public class MyTogglzConfiguration implements TogglzConfig {
        @Override
        public UserProvider getUserProvider() {
            return new UserProvider() {
                @Override
                public FeatureUser getCurrentUser() {
                    return new SimpleFeatureUser("admin", true);
                }
            };
        }
    }

If you want to authenticate the user, instead of the above dummy one , implement your own UserProvider by following this documentation

于 2016-06-07T06:20:04.990 回答
1

Please add the below in your application.yml or application.properties:

togglz:
  console:
    enabled: true
    path: /togglz-console
    use-management-port: false

or

togglz.console.enabled: true
togglz.console.path: /togglz-console
togglz.console.use-management-port: false

Setting togglz.console.use-management-port to false will always run the Admin Console on the application port.

于 2020-10-22T15:00:30.597 回答