0

在 JUnit 测试期间无法访问 H2 数据库控制台。由于只有在测试运行时数据库才会启动并运行,所以我尝试设置断点或睡眠命令来保持测试执行以在浏览器中访问 http://localhost:8080/h2-console,但得到“无法访问此站点”错误。

我正在使用的睡眠命令:TimeUnit.MINUTES.sleep(2);

POM.xml

spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:db;DB_CLOSE_DELAY=-1;Mode=PostgreSQL
spring.datasource.username=sa
spring.datasource.password=sa
hibernate.hbm2ddl.auto=create
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.jpa.hibernate.ddl-auto=none
spring.jpa.properties.hibernate.default_schema=
logging.level.root=DEBUG
hibernate.show_sql=true
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.hibernate.use-new-id-generator-mappings=true
hibernate.dialect=org.hibernate.dialect.H2Dialect
4

0 回答 0