java - Why would import.sql fail in Spring Boot? -


i've followed this tutorial on spring boot.

the guy goes seems same our code. when point view h2 console noticed i'm missing speaker table.

i've seen lots of questions on here, blogs everywhere, , seems all have have file in main/resources , works. well, doesn't!

some of answers talk persistence.xml and/or configuration file h2. well, don't have , neither tutorial , yet works.

i'm finding of seemingly simple things terribly frustrating spring , i'm sick of looking around , finding same answer doesn't work.

can shed light on why fail?

i can't imagine else need aside pom.xml since tutorial adds import.sql , else claims - works. add more if needed.

pom.xml

<?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">     <modelversion>4.0.0</modelversion>      <groupid>org.test</groupid>     <artifactid>demo</artifactid>     <version>0.0.1-snapshot</version>     <packaging>jar</packaging>      <name>demo</name>     <description>demo project spring boot</description>      <parent>         <groupid>org.springframework.boot</groupid>         <artifactid>spring-boot-starter-parent</artifactid>         <version>1.2.6.release</version>         <relativepath/> <!-- lookup parent repository -->     </parent>      <properties>         <project.build.sourceencoding>utf-8</project.build.sourceencoding>         <java.version>1.8</java.version>     </properties>      <dependencies>         <dependency>             <groupid>org.springframework.boot</groupid>             <artifactid>spring-boot-starter-actuator</artifactid>         </dependency>         <dependency>             <groupid>org.springframework.boot</groupid>             <artifactid>spring-boot-starter-data-jpa</artifactid>         </dependency>         <dependency>             <groupid>org.springframework.boot</groupid>             <artifactid>spring-boot-starter-data-rest</artifactid>         </dependency>         <dependency>             <groupid>org.springframework.boot</groupid>             <artifactid>spring-boot-starter-security</artifactid>         </dependency>         <dependency>             <groupid>org.springframework.boot</groupid>             <artifactid>spring-boot-starter-web</artifactid>         </dependency>          <dependency>             <groupid>com.h2database</groupid>             <artifactid>h2</artifactid>         </dependency>         <dependency>             <groupid>org.springframework.boot</groupid>             <artifactid>spring-boot-starter-test</artifactid>             <scope>test</scope>         </dependency>          <dependency>             <groupid>org.springframework.boot</groupid>             <artifactid>spring-boot-configuration-processor</artifactid>             <optional>true</optional>         </dependency>     </dependencies>      <build>         <plugins>             <plugin>                 <groupid>org.springframework.boot</groupid>                 <artifactid>spring-boot-maven-plugin</artifactid>             </plugin>         </plugins>     </build> </project> 

import.sql

insert speaker(id, first_name, last_name, twitter, bio) values (0, 'foo', 'baz', 'foobaz', 'foo baz hates twitter'); insert speaker(id, first_name, last_name, twitter, bio) values (1, 'bar', 'baz', 'barbaz', 'bar baz hates twitter too'); insert speaker(id, first_name, last_name, twitter, bio) values (2, 'santa', 'clause', 'saintnick', 'santa twitter champ'); 

i found answer in minor important detail little more careful investigation. apparently, when console started added default values form entries , 1 differed tutorial's.

for jdbc url default jdbc:h2:~/test.

enter image description here

i had change jdbc:h2:mem:testdb.

enter image description here

i'm able see speaker table , data.

once made change stayed default. suppose author had done , missed difference.

thanks @m. deinum!


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -