I tried various approach but I am confused now, I have spring boot application for which I'm writing integration test with inmemory h2 database.
this is 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
and I start the console by starting the server from here to test it in debug mode of test
@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;
}
I'm able to view the console on 8081 port but I am not able to see the schema which I popultaed from yml file. Please help.
我不确定为什么这不起作用但我通过java代码创建一个用于数据源的bean并从那里加载脚本。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.