title: Spring Boot - Loading Initial Data to Database
body: <p>I have a little problem. I have a Spring Boot Application and I will fill my H2 database with data. But I can not load the initial database data from the data-h2.sql file.</p>
  <p>Model:</p>
  <pre><code>@Getter
  @Setter
  @NoArgsConstructor
  @Entity
  @Table(name = &quot;mood&quot;)
  public class Mood {
  
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Column(name = &quot;mood_id&quot;)
      private int id;
  
      @Column(name = &quot;name&quot;)
      private String name;
  
      public Mood(String name) {
          this.name = name;
      }
  
      public Mood(int id, String name) {
          this.id = id;
          this.name = name;
      }
  }
  </code></pre>
  <p>data-h2.sql file:
  <code>INSERT INTO mood (name) VALUES ('Good');</code></p>
  <p>application.properties:</p>
  <pre><code>spring.datasource.url=jdbc:h2:mem:mooddb;
  spring.datasource.driverClassName=org.h2.Driver
  spring.datasource.username=a
  spring.datasource.password=a
  spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
  spring.jpa.hibernate.ddl-auto=create
  
  spring.h2.console.enabled=true
  
  spring.jpa.show-sql=true
  spring.jpa.properties.hibernate.format_sql=true
  
  spring.jpa.defer-datasource-initialization=true
  
  spring.h2.console.path=/h2-console
  spring.h2.console.settings.trace=false
  spring.h2.console.settings.web-allow-others=false```
  
  Sorry for the formatation, that is my first question :)
  </code></pre>