java Spring启动+H2 Db到文件+/h2console
我正在做一个项目,我需要迁移数据库,并在一个文件开发环境中使用H2数据库
我将flyway dependendy添加到Spring Boot(1.4.0.RELEASE)web应用程序的pom中:
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
</dependency>
然后我在应用程序上配置了db和flyway。属性:
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.datasource.url=jdbc:h2:file:./db/pippo.db;
spring.datasource.username=pippo
spring.datasource.password=pluto
flyway.enabled=true
flyway.url=jdbc:h2:file:./db/pippo.db
flyway.user=pippo
flyway.password=pluto
flyway.locations=classpath:db/migration
然后,如果我启动应用程序,它会正确地创建数据库文件/db/pippo。db。。。所以我想一切都会很好,但当我在浏览器上写http://localhost:8081/h2-console时,我收到404响应。 我的配置有什么问题
谢谢大家
# 1 楼答案
确保h2始终依赖于作用域“compile”、作用域“runtime”等。这将导致h2控制台出现故障。您需要确保添加了一个servlet映射“/h2 console/*”