如果您在启用 Spring Security 之前在 Spring Boot 中使用过 H2 控制台(无论有或没有 Vaadin),您可能会注意到添加 Spring Security 会阻止对数据库控制台的访问。要解决此问题,最简单的方法是重写 configure(WebSecurity web) 方法。请注意方法签名,因为还有一个 configure(HttpSecurity http) 方法,这对解决此问题没有帮助。
要重新获得对 H2 控制台的访问权限,您通常需要执行以下操作:
1
2
3
4
5
6
7
@覆盖
protected void configure(WebSecurity web) 抛出异常 {
网络
.ignoring()
.requestMatchers(new AntPathRequestMatcher("/h2-console/"));
超级配置(网络);
}
仅此而已!
以上就是将 Honsole 与 Spring Security 结合使用的详细内容,更多请关注其它相关文章!