Spring-boot populate H2 database with schema.sql and data.sql
<p>I set up Spring-boot to work with H2 in-memory database
<code>application.properties</code> file is in the <code>/config</code> directory
and it looks like, this file is processed</p>
<pre class="lang-ini prettyprint-override"><code>spring.datasource.url=jdbc:h2:mem:mydb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.h2.console.path=/myconsole
spring.h2.console.enabled=true
spring.datasource.initialize=true
spring.datasource.schema=schema.sql
spring.datasource.data=data.sql
</code></pre>
<p>This file is processed and the console appears at <code>/myconsole</code>
But the <code>schema.sql</code> and <code>data.sql</code> are not processed and db is empty.
I placed <code>schema.sql</code> and <code>data.sql</code> files both under <code>/config</code> and <code>/src/main/resources</code>.</p>
<p>SQL language instructions are correct and I can populate the table using console input.</p>
<p>Another strange thing is
even though i name db as</p>
<pre class="lang-ini prettyprint-override"><code>spring.datasource.url=jdbc:h2:mem:mydb
</code></pre>
<p>the spring console loads another database <code>testdb</code></p>
<pre><code>o.s.j.d.e.EmbeddedDatabaseFactory --- Starting embedded database: url='jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false', username='sa'
</code></pre>
<p>How to load the H2 database correctly?</p>