首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Togglz控制台错误403 Spring Boot

Togglz控制台错误403 Spring Boot
EN

Stack Overflow用户
提问于 2016-09-06 07:50:22
回答 2查看 1.7K关注 0票数 4

我试图在Spring上运行Togglz控制台,但是我在屏幕上看到了这个:

代码语言:javascript
复制
(type=Forbidden, status=403). You are not allowed to access the Togglz Console.

我刚刚注意到很多人都有同样的问题,一些解决办法对他们有效。但我不明白我做错了什么。

这里我的代码:

MyFeatures

代码语言:javascript
复制
  public enum MyFeatures implements Feature {

    @EnabledByDefault
    @Label("The list of employees can be displayed")
    SHOW_LIST,

    @Label("Second Feature")
    FEATURE_TWO;

    public boolean isActive() {
        return FeatureContext.getFeatureManager().isActive(this);
    }


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

MyTogglzConfiguration

代码语言:javascript
复制
public class MyTogglzConfiguration implements TogglzConfig {
@Override
public Class<? extends Feature> getFeatureClass() {
    return null;
}

@Override
public StateRepository getStateRepository() {
    return null;
}


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

我的依赖关系:

代码语言:javascript
复制
<dependency>
        <groupId>org.togglz</groupId>
        <artifactId>togglz-console</artifactId>
        <version>2.3.0.RC1</version>
    </dependency>
    <dependency>
        <groupId>org.togglz</groupId>
        <artifactId>togglz-spring-boot-starter</artifactId>
        <version>2.3.0.Final</version>
</dependency>

application.properties

代码语言:javascript
复制
togglz:
enabled:true # Enable Togglz for the application.
feature-enums:# Comma-separated list of fully-qualified feature enum class names.
feature-manager-name:# The name of the feature manager.
features:# The feature states. Only needed if feature states are stored in application properties.
HELLO_WORLD:true
REVERSE_GREETING:true
REVERSE_GREETING.strategy:username
REVERSE_GREETING.param.users:user2, user3
features-file:# The path to the features file that contains the feature states. Only needed if feature states are stored in external properties file.
features-file-min-check-interval:# The minimum amount of time in milliseconds to wait between checks of the file's modification date.
cache:
enabled:false # Enable feature state caching.
time-to-live:0 # The time after which a cache entry will expire.
time-unit:milliseconds # The time unit as java.util.concurrent.TimeUnit enum name (one of "nanoseconds", "microseconds", "milliseconds", "seconds", "minutes", "hours", "days").
console:
enabled:true # Enable admin console.
path:/togglz-console # The path of the admin console when enabled.
feature-admin-authority:ROLE_ADMIN # The name of the authority that is allowed to access the admin console.
secured:false # Indicates if the admin console runs in secured mode. If false the application itself should take care of securing the admin console.
endpoint:
id:togglz # The endpoint identifier.
enabled:true # Enable actuator endpoint.
sensitive:true # Indicates if the endpoint exposes sensitive information.

如果有人能帮我的忙我会很感激的。

谢谢!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-09-09 11:33:46

我已经发现了我做错了什么,所以我的建议是:

  1. 不需要MyTogglzConfiguration类
  2. 将application.properties更改为application.yml
  3. 对togglz控制台使用Security或禁用make。

我更新的应用程序属性(application.yml):

代码语言:javascript
复制
   togglz.console.enabled: true

   togglz:
     feature-enums: service.Features
     console:
      path: /togglz-console
      secured: false
票数 1
EN

Stack Overflow用户

发布于 2018-08-09 21:29:23

当您在类路径中拥有与togglz相关的单元测试jar文件时,就会发生这种情况。

在我的例子中,我在类路径中得到了togglz- the .2.1.0.final.jar。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39343417

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档