Spring-boot populate H2 database with schema.sql and data.sql

后端 未结 1 497
难免孤独
难免孤独 2021-02-05 16:42

I set up Spring-boot to work with H2 in-memory database application.properties file is in the /config directory and it looks like, this file is process

相关标签:
1条回答
  • 2021-02-05 17:03

    Resolved the issue.

    The spring boot app requires its ownd jdbc dependency

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
    

    NON-boot dependency, that I had, is NOT enough alone:

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
    </dependency>
    

    Without the "spring-boot-starter-jdbc" dependency "spring.datasource.url" settings in file "application.properties" are not processed. That file is actually processed, but not the jdbc settings. Spring boot will create its own testdb in the memory, which destroys the data after closing the application.

    0 讨论(0)
提交回复
热议问题