O'Reilly logo

Learning Spring Boot by Greg L. Turnquist

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Loading data using a SQL script

Note

This isn't a primer on JPA. This chapter will use bits of Spring Data and JPA to show you how Spring Boot makes things simpler when accessing data. However, you should do extra reading if you aren't already familiar with JPA and the various tradeoffs you have to make for your development needs.

To get things going, we need to indicate what type of database we are using. Create src/main/resources/application.properties with the following settings:

spring.datasource.platform: h2

This immediately signals Spring Boot that we are using H2. Spring Boot will look for data.sql as well as data-${platform}.sql files to run. It uses Spring JDBC to do this (which was pulled in transitively by spring-boot-starter-data-jpa

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required