Building Applications with Spring 5 and Kotlin

Book description

Learn to build a full-fledged application in Spring and Kotlin taking a reactive, microservice-based approach for scalability and robustness in the cloud

About This Book
  • Build a full-fledged application in Spring and Kotlin
  • Architect your application to take a microservice-based approach in the cloud
  • Integrate your application with a variety of Spring components
Who This Book Is For

Developers comfortable using Spring who have basic knowledge of Kotlin and want to take their development skills to the next level and build enterprise-grade applications will benefit from this book.

What You Will Learn
  • Explore Spring 5 concepts with Kotlin
  • Learn both dependency injections and complex configurations
  • Utilize Spring Data, Spring Cloud, and Spring Security in your applications
  • Create efficient reactive systems with Project Reactor
  • Write unit tests for your Spring/Kotlin applications
  • Deploy applications on cloud platforms like AWS
In Detail

Kotlin is being used widely by developers because of its light weight, built-in null safety, and functional and reactive programming aspects. Kotlin shares the same pragmatic, innovative and opinionated mindset as Spring, so they work well together. Spring when combined with Kotlin helps you to reach a new level of productivity. This combination has helped developers to create Functional Applications using both the tools together. This book will teach you how to take advantage of these developments and build robust, scalable and reactive applications with ease.

In this book, you will begin with an introduction to Spring and its setup with Kotlin. You will then dive into assessing the design considerations of your application. Then you will learn to use Spring (with Spring Boot) along with Kotlin to build a robust backend in a microservice architecture with a REST based collaboration, and leverage Project Reactor in your application. You'll then learn how to integrate Spring Data and Spring Cloud to manage configurations for database interaction and cloud deployment. You'll also learn to use Spring Security to beef up security of your application before testing it with the JUnit framework and then deploying it on a cloud platform like AWS.

Style and approach

Everything you learn will be demonstrated on real-world Spring project. In each chapter we will cover some of Spring features and apply it on our project. We will guide you from the project initialization till the project deployment.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Building Applications with Spring 5 and Kotlin
  3. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Starting Up
    1. What is your mission?
    2. Separating code into independent entities
      1. Describing entities
    3. Planning your development
    4. Preparing the working environment
      1. Installing Git
        1. Microsoft Windows
        2. macOS
        3. Linux
          1. Debian and Ubuntu
          2. Fedora
      2. Building Git from the source code
        1. Debian and Ubuntu
        2. Fedora
      3. Installing JDK
        1. Microsoft Windows
        2. Linux
        3. macOS
      4. Installing the IDE
        1. Microsoft Windows
        2. Linux
        3. macOS
      5. Starting IntelliJ for the first time
      6. Installing Spring 5
        1. Maven installation
        2. Gradle installation
      7. Installing Postman
        1. Microsoft Windows installation
        2. Linux installation
        3. macOS installation
    5. Setting up a Git repository
    6. Summary
  7. Starting with Spring
    1. What is Spring?
      1. What features does it offer?
        1. Dependency injection
        2. Inversion of Control (IoC)
        3. Aspect Oriented Programming (AOP)
        4. Container
        5. MVC framework
          1. Model
          2. View
          3. Controller
        6. Transaction management
        7. Misc
      2. How well is Kotlin supported?
    2. Creating Spring project
      1. What is Spring Initializr?
      2. Generating the project
    3. Creating Spring project with IntelliJ
    4. Summary
  8. Building Your First Spring RESTful Service with Kotlin
    1. Defining dependencies for our project
    2. Our first controller
      1. What else is available?
    3. Adding a data class
      1. Drafting other API calls
    4. Running the application
      1. Accessing Actuator endpoints
    5. Adding an @Service component
    6. Summary
  9. Working with Spring Data JPA and MySQL
    1. Introducing Spring Data JPA
      1. What does Spring Data provide?
      2. Which Spring Data modules do we need?
      3. About Spring Data JPA
    2. Installing MySQL
      1. Installing MySQL Community Server on macOS
      2. Installing MySQL Community Server on Windows
      3. Installing MySQL Community Server on Linux
      4. Using a software package manager
      5. Using TAR
    3. Creating a schema
      1. Extending dependencies
    4. CRUD operations
      1. Insert
      2. Update
      3. Select
      4. Delete
      5. More regarding updates
      6. Introducing DTOs
    5. Creating database queries
      1. Named queries
    6. Summary
  10. Securing Applications with Spring Security
    1. Introducing Spring Security
      1. Defining user roles
      2. Defining classes for each role
      3. Defining DTOs for the user
    2. Securing your REST API with basic authentication
    3. What else can Spring Security do?
    4. Summary
  11. Spring Cloud
    1. Microservice architecture versus SOA
    2. Understanding microservice architectures
    3. Microservices with Spring Cloud
      1. Spring Cloud in practice
      2. Configuration server
      3. Discovery
      4. Gateway
      5. Updating the API application
    4. Securing Spring Cloud services
    5. Summary
  12. Using Project Reactor
    1. Why use Project Reactor?
    2. What is Project Reactor?
    3. Using Project Reactor
    4. Summary
  13. Development Practices
    1. Challenging development practices
      1. Reviewing dependency injection
      2. Making your classes too open
      3. Mutability
      4. Multithreading
      5. Not validating data
      6. Tests coverage
      7. XML configurations
    2. Good ways to develop your code
      1. Don't inject too much
      2. Use a closed-visibility approach
      3. Solving the multithreading issue
      4. Spring data validation
    3. Summary
  14. Testing
    1. Why is testing a crucial part of development?
      1. So, what is testing?
      2. Common test practices and approaches
    2. Preparing our project
    3. Writing our first test with Kotlin
    4. Running the test in InteliJ IDEA
    5. Testing Spring REST applications
    6. Running test suites
    7. Summary
  15. Project Deployment
    1. What will be deployed?
    2. Deployment options
      1. Deploying the Tomcat application server
      2. Deploying to the Java EE application server
    3. Deploying to the Cloud (AWS)
    4. Summary
  16. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Building Applications with Spring 5 and Kotlin
  • Author(s): Milos Vasic
  • Release date: May 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788394802