Book Image

Spring MVC Cookbook

By : Alexandre Bretet, Alex Bretet
Book Image

Spring MVC Cookbook

By: Alexandre Bretet, Alex Bretet

Overview of this book

Spring MVC is a lightweight application framework that comes with a great configuration by default. Being part of the Spring Framework, it naturally extended and supported it with an amazing set of recognizable annotations. External libraries can be plugged in and plugged out. It also possesses a request flow. Complete support of REST web services makes the Spring architecture an extremely consistent choice to support your front-end needs and Internet transformations. From the design of your Maven modules, you will achieve an Enterprise-standard for a stateless REST application based on Spring and Spring MVC with this book. This guide is unique in its style as it features a massive overview of practical development techniques brought together from the Spring ecosystem, the new JEE standards, the JavaScript revolution and Internet of Things. You will begin with the very first steps of Spring MVC's product design. Focused on deployment, viability, and maintainability, you will learn the use of Eclipse, Maven, and Git. You will walk through the separation of concerns driven by the microservices principles. Using Bootstrap and AngularJS, you will develop a responsive front-end, capable of interacting autonomously with a REST API. Later in the book, you will setup the Java Persistence API (JPA) within Spring; learn how to configure your Entities to reflect your domain needs, and discover Spring Data repositories. You will analyze how Spring MVC responds to complex HTTP requests. You will implement Hypermedia and HATEOAS to guide your customer's stateless conversation with the product and see how a messaging-service based on WebSocket can be configured. Finally you will learn how to set up and organize different levels of automated-tests, including logging and monitoring.
Table of Contents (16 chapters)
Spring MVC Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Introduction


Before we dive into this routine for initializing the developments, we are going to answer, as an introduction, a couple of questions that should help you understand the routine better.

Remember that the result of this chapter will also constitute the minimal starting point for all the further chapters.

Note

Let's do it with fun!

Throughout this book, we will be acting on behalf of the ZipCloud company. ZipCloud aims to build different products in the social and financial industry. We are going to build the first product of the company: cloudstreetmarket.com which will be a wonderful stock exchange platform with social capabilities. This project must be an optimal beginning for this little ZipCloud start-up!

Why such a routine?

Whatever your initial objectives may be, it is necessary to make sure that the design will not suffer from early stage failures. This routine should cover you against this risk.

The idea beyond the routine itself is to share a bootstrap methodology to kick off the project base that you need now and that will support your needs tomorrow. The routine is also a key to drive your product thoughts toward a sustainable architecture which will be easy to refactor and to maintain.

Setting up a new project for an enterprise-level architecture will not kill the excitement and creativity!

Why making use of the Eclipse IDE?

There is competition in the domain, but Eclipse is popular among the Java community for being an active open source solution; it is consequently accessible online to anyone with no restrictions. It also provides, among other usages, a very good support for web implementations and particularly to MVC web implementations.

Why making use of Maven?

Maven is a software project management and comprehension tool. It is an open source project supported by the Apache community and the Apache Software Foundation. For nearly 10 years, Maven has given massive benefits. It has also shaped a standard structure for Java projects. With its Project Object Model (POM) approach, it provides, to anyone and potentially to any third-party software, a uniform and radical way of understanding and building a Java project hierarchy with all its dependencies.

In early stage architectures, it is critical to consider the following decisions:

  • Opening the project definition to potentially different development environments and continuous integration tools

  • Monitoring the dependencies and maybe securing their access

  • Imposing a uniform directory structure within the project hierarchy

  • Building a self-tested software with self-tested components

Choosing Maven secures these points and fulfills our project's need to make our project reusable, secure, and testable (under automation).

What does the Spring Framework bring?

The Spring Framework and its community have contributed to pulling forward the Java platform for more than a decade. Presenting the whole framework in detail would require us to write more than a book. However, the core functionality based on the principles of Inversion of Control (IOC) and Dependency Injection (DI) through a performant access to the bean repository allows considerable reusability. Staying lightweight, it secures great scaling capabilities and could probably suit all modern architectures.