Java Spring引导与H2 inmemory数据库的集成测试

Java Spring引导与H2 inmemory数据库的集成测试,java,spring,spring-boot,integration-testing,h2,Java,Spring,Spring Boot,Integration Testing,H2,我尝试了各种方法,但我现在感到困惑,我有一个spring引导应用程序,我正在为它编写使用inmemory h2数据库的集成测试 这是application.yml spring.profiles: test spring.datasource: url: jdbc:h2:mem:AZ;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE username: sa password: driver-class-name: org.h2.D

我尝试了各种方法,但我现在感到困惑,我有一个spring引导应用程序,我正在为它编写使用inmemory h2数据库的集成测试

这是application.yml

spring.profiles: test
spring.datasource:
    url: jdbc:h2:mem:AZ;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
    username: sa
    password:
    driver-class-name: org.h2.Driver
    platform: h2
    # enable H2 web console and set url for web console
      # http://localhost:8080/console
    h2:
      console:
        enabled: true
        path: /console
    schema: schema.sql
    data: data.sql
我通过从这里启动服务器来启动控制台,以调试模式测试它

@Bean
public ServletRegistrationBean h2servletRegistration() throws SQLException {
    Server webServer = Server.createWebServer("-web", "-webAllowOthers", "-webPort", "8081");
    webServer.start();
    ServletRegistrationBean registration = new ServletRegistrationBean(new WebServlet());
    registration.addUrlMappings("/console/*");
    return registration;
}

我可以在8081端口上查看控制台,但无法看到从yml文件中移植的模式。请提供帮助。

我不知道为什么这不起作用,但我通过java代码为datasource创建了一个bean,并从中加载了脚本。尝试在URL中使用mode,例如:mode=MYSQL。您能看到正在加载到DB中的sql吗?@guringrespanesar尝试了否luck@AdamSmith我正试图通过控制台调查此事,我无法从那里看到,如何检查这个?我有一个疑问,我这样做对吗?我正在启动服务器ans是否也有yml配置?如果这会创建两个不同的内存数据库?