Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 如何使用h2数据库和yaml属性将flyway引入spring boot项目?_Spring Boot_Properties_Yaml_H2_Flyway - Fatal编程技术网

Spring boot 如何使用h2数据库和yaml属性将flyway引入spring boot项目?

Spring boot 如何使用h2数据库和yaml属性将flyway引入spring boot项目?,spring-boot,properties,yaml,h2,flyway,Spring Boot,Properties,Yaml,H2,Flyway,我正在尝试使用h2和yaml属性将flyway库集成到spring boot项目中。不幸的是,在启动应用程序时,我没有收到任何关于Flyway已启动的日志,而且我也看不到h2控制台下的表。(我看到另一个由hibernate创建的表) 这是我的代码: pom.xml src/main/resources/db/migration下的V1_0_init.sql CREATE TABLE TEST_USERS (ID INT AUTO_INCREMENT PRIMARY KEY, USERID VAR

我正在尝试使用h2和yaml属性将flyway库集成到spring boot项目中。不幸的是,在启动应用程序时,我没有收到任何关于Flyway已启动的日志,而且我也看不到h2控制台下的表。(我看到另一个由hibernate创建的表)

这是我的代码:

pom.xml

src/main/resources/db/migration下的V1_0_init.sql

CREATE TABLE TEST_USERS (ID INT AUTO_INCREMENT PRIMARY KEY, USERID VARCHAR(45));
INSERT INTO USERS (ID, USERID) VALUES (1, 'TEST.com');
你知道怎么了吗

  • 要在启动时自动运行Flyway数据库迁移,应在pom.xml中添加Flyway依赖项:
  • 然后您应该在启动时看到flyway日志

    有关更多信息:

    您使用的maven命令是什么?(因为我看到你使用的是maven插件,而不是依赖项)
    spring:
        h2:
            console:
                enabled: true
                path: /h2-console
        datasource:
            url: jdbc:h2:file:~/testdb
            username: sa
            password:
            driverClassName: org.h2.Driver
        jpa:
            hibernate.ddl-auto: none
            show-sql: true
        flyway:
            enabled: true
            locations: filesystem:/db/migration
    
    CREATE TABLE TEST_USERS (ID INT AUTO_INCREMENT PRIMARY KEY, USERID VARCHAR(45));
    INSERT INTO USERS (ID, USERID) VALUES (1, 'TEST.com');
    
        <dependency>
          <groupId>org.flywaydb</groupId>
          <artifactId>flyway-core</artifactId>
        </dependency>
    
      flyway:
        locations: classpath:/db/migration