H2 控制台错误:找不到适合 08001/0 的驱动程序

fil*_*zyk 8 java spring h2 spring-boot

您好,我在 H2 控制台数据库中查看我的架构时遇到问题:

我使用弹簧靴:

spring.datasource.initialize=true
spring.datasource.url=jdbc:h2:~/test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MV_STORE=FALSE;MVCC=FALSE
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.h2.console.enabled=true
Run Code Online (Sandbox Code Playgroud)

这是我的登录页面:

在此处输入图片说明

所以我在里面看到的是标准的控制台视图,没有我的表,但我的应用程序运行良好。

Lub*_*ubo 5

通常“测试连接”有效(登录表单后的绿线),但连接无效。这可能是由处理标头引起的,这可能是由过滤器或安全配置引起的。例如,我被这个击中了两次:

  1. 我有相同的症状,问题是由使用日志记录引起的。删除依赖项有助于摆脱登录 h2-console 时找不到 08001/0消息的合适驱动程序

    <dependency>
        <groupId>org.zalando</groupId>
        <artifactId>logbook-spring-boot-starter</artifactId>
    </dependency>
    
    Run Code Online (Sandbox Code Playgroud)

我不确定,这是给定项目的错误,还是错误的用法/配置。

  1. 配置 OAuth2 也让我感到震惊。我需要从 web 和 http 安全中排除 h2-console uri。在这里查看一些信息。看片段:

    @Configuration
    @EnableWebSecurity
    @EnableGlobalMethodSecurity(
            securedEnabled = true,
            jsr250Enabled = true,
            prePostEnabled = true
    )
    @RequiredArgsConstructor
    public class SecurityConfig extends WebSecurityConfigurerAdapter {
        @Override
        public void configure(WebSecurity web) {
            web.ignoring().antMatchers("/h2-console/**");
        }
        @Override
        protected void configure(HttpSecurity http) throws Exception {
            http
                    // only part of config is shown here...
                    .authorizeRequests()
                    .antMatchers("/",
                            "/error",
                            "/favicon.ico",
                            "/**/*.png",
                            "/**/*.gif",
                            "/**/*.svg",
                            "/**/*.jpg",
                            "/**/*.html",
                            "/**/*.css",
                            "/**/*.js",
                            "/h2-console/**")
                    .permitAll()
                    .antMatchers("/auth/**", "/oauth2/**").permitAll()
                    .anyRequest().authenticated()
                    .and()
                    .oauth2Login();
        }
    }
    
    Run Code Online (Sandbox Code Playgroud)


Kum*_*lav -2

在 H2 控制台中使用整个字符串进行连接,即,您将只看到您的表

jdbc:h2:~/test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MV_STORE=FALSE;MVCC=FALSE