From the course: Creating Your First Spring Boot Microservice

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Invoking the Spring Data JPA repositories

Invoking the Spring Data JPA repositories

From the course: Creating Your First Spring Boot Microservice

Start my 1-month free trial

Invoking the Spring Data JPA repositories

- [Instructor] We need to load the database with the collection of predefined tours and tour packages. Our application uses an in memory H2 database. Therefore we need to load the data each time the application starts. So now we have services to create the tours and into our tour packages. But how should we invoke them before the Tomcat starts up? Remember explorecali application class? in that class we have access to the application starting point. So I already have auto wired tour package service and tour service in Explore Cali Application. And there's also a method that says "load tours that startup," and what that will do is create the tour packages and create the tours. And after each one of those I'm going to call the service to say what are the total number of packages and what are the total number of tours. The main method does not have access to the services because it's static and its class scope, not object…

Contents