Book Image

Learning Spring Boot

By : Greg L. Turnquist
Book Image

Learning Spring Boot

By: Greg L. Turnquist

Overview of this book

<p>This practical, accessible guide helps you get up and running fast with Spring Boot. This book starts by crafting a Spring MVC application using the Spring stack on top of Apache Tomcat, with little configuration on from your end. You will also learn how to write both JUnit and Spock test cases. Then, you'll pull back the curtain and see how Spring Boot works by using Spring Messaging (JMS and AMQP) as well as creating custom metrics, custom information, and custom CLI commands aimed at production environments. In the last two chapters, you'll see how Spring Boot supports everyday situations we all deal with. You will learn how to create multiple configurations inside your app that can interact with different data stores.</p> <p>By the end of the book, you'll have a good understanding of how Spring Boot works, how it manages low-level infrastructure, and how to start out production-grade apps with built-in support tools as well as custom ones.</p>
Table of Contents (13 chapters)
Learning Spring Boot
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Configuring user data to persist


So far, our configuration is quite extensive. We have created multiple accounts, with each user possessing different roles. However, this is an in-memory storage mechanism. To upgrade our app to support a complete production environment, we can borrow some of the concepts visited in Chapter 4, Data Access with Spring Boot. In that chapter we learned how to switch between an in-memory database and a persistent one using Spring Profiles. We'll do the same thing here and see what options Spring Security offers at the same time.

For starters, we need to add mysql-connector-java to build.gradle so that the dependencies section looks like the following code:

dependencies {
    compile("org.springframework.boot:spring-boot-starter-thymeleaf")
    compile("org.springframework.boot:spring-boot-starter-data-jpa")
    compile("org.springframework.boot:spring-boot-starter-security")
    compile("org.thymeleaf.extras:thymeleaf-extras-springsecurity3")
    compile("org.springframework...