Integrating Spring Boot and JPA
Integrating a JPA project into Spring Boot is simple.
-
We will do this by creating a separate Spring Boot Project, and using Gradle to pull the JPA project into it.
-
Gradle automates the inclusion of the JPA project into the Spring Boot Project. Each time our Web Project is built/deployed, Gradle loads in the JPA project.
Practice Exercise¶
NOTE: This setup process is a good template for how to set up your group project.
Drill¶
NOTE: STS makes multiple project builds a little bit difficult to manage with a single Github repository. As a result, we recommend that you create a new workspace as an umbrella for each new site. In this workspace you will create a JPA and Spring Boot project. You will then initialize that workspace as a Git repository.
For this drill, we will use the existing VideoStore workspace.
- Open your VideoStore workspace.
- Execute a Gradle Refresh on your project to bring in all dependencies.
- In the Gradle Tasks view, run the
verification|testtask and make sure all your JPA unit tests pass.- Create a new Spring Starter Project with the name
BootMVCVideoStore.- Set the Type to
Gradle.- Set the Java Version to
8.- Set the Packaging to
War.- Set the Package to
com.example.bootmvc.- Add the
Spring Web,Spring Data JPA, andMySQL Driverdependencies to your project.- Be sure to include all three dependencies.
- Build the project with
Finish.