Spring Boot Web Application, Study Guides, Projects, Research of Computer science

A complete introduction to Spring Boot Web Application

Typology: Study Guides, Projects, Research

2018/2019

Uploaded on 11/27/2019

grusso74
grusso74 🇮🇹

8 documents

1 / 11

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Spring Boot Web Application and more Study Guides, Projects, Research Computer science in PDF only on Docsity!

Standard June 25,2015 by jt 67 Comments In the first part of this tutorial series on creating a web application using Spring Boot, | showed how to use Spring Initializr to create the Maven project we're using in this example. In the second part of the tutorial series, | showed you how to configure Spring MVC and ThymeLeaf templates to display a basic web page via Tomcat. In this part of my Spring Boot tutorial series, we'll setup the H2 database and Spring Data JPA. We will use these tools to persist data to the database in our Spring Boot Web Application. Database Persistence with Spring Boot Spring Boot comes with pre-configured options for relational databases. Like other things in Spring Boot, these are enabled by simply having the dependency on your classpath. While all the interest in the media is around No-SQL databases, relational databases are time proven work horses. They are not going anywhere soon. If you're doing enterprise application development with the Spring Framework, you're probably going to be using a relational database. Hibernate / JPA does a great job of abstracting the persistence layer. If you want to change from Oracle to DB2 or to MySQL, it is just a matter of changing the database drivers. The JPA mapping code you use on your domain POJOs doesn’t change. Your application code does not change. NOTE — the above statement is 95% true. When changing databases with complex mappings, you're going to hit minor edge cases here and there. When developing Spring applications, it is very common to use a in memory database for your development, and then a real database installation for your testing and production environments. Oracle is a great database, but it's also BIG and resource intensive. I've run Oracle on a laptop. It takes a lot of resources. Its a great database, but its not really meant to run from a laptop. The persistence API in Java follows the Interface Segregation design principle of object oriented design. So, its easy to plug in a different persistence implementation. With Spring managing the depencency injection for us, it makes swapping databases in and out very easy. What we are going to do in this tutorial is setup an in-memory database, configure a JPA entity, setup Hibernate to automatically create the database tables, and on startup add data to the database for our use and testing. By doing this, each time we start our application, we have a newly created database, with known data populated into the database tables. It sounds like a lot of work, but it’s really not much. And it does not add very much to your startup time. With the speed of modern computers, even a complex set of tables and data is going to load in just a few seconds. The advantage of doing this for you as the developer is you're working against known data while you are doing