Zha*_* Yi 5 jersey togglz spring-boot
我的 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")
Run Code Online (Sandbox Code Playgroud)
在我的引导类中,我添加了以下代码:
@Bean
public FeatureProvider featureProvider() {
return new EnumBasedFeatureProvider(AppFeatures.class);
}
Run Code Online (Sandbox Code Playgroud)
启动应用程序后,我可以从此链接看到 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/*]
Run Code Online (Sandbox Code Playgroud)
下面是我的 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.
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么?
Step1添加以下依赖:
<!-- Togglz Admin Console -->
<dependency>
<groupId>org.togglz</groupId>
<artifactId>togglz-console</artifactId>
<version>2.3.0.RC1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
步骤2在 application.yml 或 application.properties 中添加以下内容
togglz:
console:
enabled: true # Enable admin console.
Run Code Online (Sandbox Code Playgroud)
或者
togglz.console.enabled: true # Enable admin console.
Run Code Online (Sandbox Code Playgroud)
Step3配置控制台路径
togglz:
console:
path: /togglz-console # The path of the admin console when enabled.
Run Code Online (Sandbox Code Playgroud)
对于身份验证:添加一个虚拟 UserProvider,为每个用户分配管理员权限:
public class MyTogglzConfiguration implements TogglzConfig {
@Override
public UserProvider getUserProvider() {
return new UserProvider() {
@Override
public FeatureUser getCurrentUser() {
return new SimpleFeatureUser("admin", true);
}
};
}
}
Run Code Online (Sandbox Code Playgroud)
如果您想对用户进行身份验证,请按照此文档实现您自己的 UserProvider,而不是上面的虚拟用户
归档时间: |
|
查看次数: |
5376 次 |
最近记录: |