Spring boot 无法在spring应用程序中登录H2控制台

Spring boot 无法在spring应用程序中登录H2控制台,spring-boot,spring-data-jpa,h2,Spring Boot,Spring Data Jpa,H2,在我的spring应用程序中,我添加了devtools依赖项 因此,我可以使用H2控制台,如下所示: 我还没有为H2做任何额外的配置。所以我希望“连接”按钮可以让我进入数据库。但我得到的却是: 编辑:我已经实现了spring安全性 protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers(

在我的spring应用程序中,我添加了devtools依赖项

因此,我可以使用H2控制台,如下所示:

我还没有为H2做任何额外的配置。所以我希望“连接”按钮可以让我进入数据库。但我得到的却是:

编辑:我已经实现了spring安全性

protected void configure(HttpSecurity http) throws Exception {
    http
            .authorizeRequests()
                .antMatchers("/path1", "/path2")
                    .access("hasRole('ROLE_USER')")
                .antMatchers("/", "/**").access("permitAll")
            .and()
                .formLogin()
                    .loginPage("/login");//the path where custom login page will be provided
}

我在这里遗漏了什么?

页面清楚地显示错误是403禁止的。请检查您的安全配置

如果您使用的是spring security,请检查扩展org.springframework.security.config.annotation.web.configuration.websecurityConfigureAdapter的配置类,重写的方法中有:

  @Override
  protected void configure(HttpSecurity http) throws Exception {
    //super.configure(http);
    http
        .authorizeRequests()
        .antMatchers("/").permitAll() // you can allow the root endpoint ( also will be containing the default /h2-console endpoint ) for all users
                                      // or put some role restriction on the specific "/h2-console" endpoint to the admin user you are going to be logging in with.
        .antMatchers("/admin/**").hasRole("ADMIN")
          .and()
        .csrf().disable() //rest of the configs below according to your needs.
        .headers().frameOptions().disable()
          .and()
        .formLogin();
  }

看起来像是安全配置问题,请共享您的安全配置。安全配置在我看来很好,您能粘贴h2控制台的访问URL和您得到的白标签错误吗?,