title: Spring Boot: H2 database not saved to file
body: <p>I'm trying to persist an H2 in-memory DB to a file with Spring Boot to reuse the data in there.</p>
  
  <p>Unfortunately, the way to specify the datasource url like</p>
  
  <pre><code>spring.datasource.url = jdbc:h2:file:~/WeatherDB;FILE_LOCK=FS
  </code></pre>
  
  <p>(<a href="https://bitbucket.org/madmarkus/springbootexploring/src/f9941fc45b2d3d6578891ebb29924bc82ec9042d/src/main/resources/application.properties?at=master" rel="noreferrer">complete application.properties</a>)</p>
  
  <p>doesn't work for me. I can't find a file generated by H2 anywhere on my hard disk (also, saved data is not available after restarting the server).</p>
  
  <p>To visualize this, I created a sample project that can be found on <a href="https://bitbucket.org/madmarkus/springbootexploring" rel="noreferrer">Bitbucket</a>.</p>
  
  <p>With that, it doesn't seem to make a difference if the application is run from an IDE with <code>gradle run</code> or after packaging it from the jar.</p>
  
  <p>What config option is needed to persist and reuse the H2 DB ?</p>
  
  <p>Update:</p>
  
  <p>I realized there is a actuator endpoint for config options at <code>http://localhost:8080/configprops</code> that shows</p>
  
  <pre><code>"spring.datasource.CONFIGURATION_PROPERTIES": {
  
      "prefix": "spring.datasource",
      "properties": {
          "schema": null,
          "data": null,
          "xa": {
              "dataSourceClassName": null,
              "properties": { }
          },
          "separator": ";",
          "url": "jdbc:h2:file:~/WeatherDB",
          "platform": "all",
          "continueOnError": false,
          "jndiName": null,
          "sqlScriptEncoding": null,
          "password": "******",
          "driverClassName": "org.h2.Driver",
          "initialize": true,
          "username": "sa"
      }
  },
  </code></pre>
  
  <p>But I just can't find an file <code>WeatherDB</code> on my harddisk nor is any data available after restarting the server.</p>
  
  <p>Any suggestions very much welcome ;-)</p>