Spring MVC Cookbook

Over 40 recipes for creating cloud-ready Java web applications with Spring MVC

Spring MVC Cookbook

This ebook is included in a Mapt subscription
Alex Bretet

Over 40 recipes for creating cloud-ready Java web applications with Spring MVC
$0.00
$22.00
$54.99
$29.99p/m after trial
RRP $43.99
RRP $54.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781784396411
Paperback466 pages

Book Description

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

Chapter 1: Setup Routine for an Enterprise Spring Application
Introduction
Installing Eclipse for JEE Developers and Java SE 8
Configuring Eclipse for Java 8, Maven 3, and Tomcat 8
Defining the project structure with Maven
Installing Spring, Spring MVC, and a web structure
Chapter 2: Designing a Microservice Architecture with Spring MVC
Introduction
Configuring a controller with simple URL mapping
Configuring a fallback controller using ViewResolver
Setting up and customizing a responsive single page webdesign with Bootstrap
Displaying a model in the View, using the JSTL
Defining a common WebContentInterceptor
Designing a client-side MVC pattern with AngularJS
Chapter 3: Working with Java Persistence and Entities
Introduction
Configuring the Java Persistence API in Spring
Defining useful EJB3 entities and relationships
Making use of the JPA and Spring Data JPA
Chapter 4: Building a REST API for a Stateless Architecture
Introduction
Binding requests and marshalling responses
Configuring content-negotiation (JSON, XML, and so on)
Adding pagination, filters, and sorting capabilities
Handling exceptions globally
Documenting and exposing an API with Swagger
Chapter 5: Authenticating with Spring MVC
Introduction
Configuring Apache HTTP to proxy your Tomcat(s)
Adapting users and roles to Spring Security
Authenticating over a BASIC scheme
Authenticating with a third-party OAuth2 scheme
Storing credentials in a REST environment
Authorizing on services and controllers
Chapter 6: Implementing HATEOAS
Introduction
Turning DTOs into Spring HATEOAS resources
Building links for a hypermedia-driven API
Choosing a strategy to expose JPA Entities
Retrieving data from a third-party API with OAuth
Chapter 7: Developing CRUD Operations and Validations
Introduction
Extending REST handlers to all HTTP methods
Validating resources using bean validation support
Internationalizing messages and contents for REST
Validating client-side forms with HTML5 AngularJS
Chapter 8: Communicating Through WebSockets and STOMP
Introduction
Streaming social events with STOMP over SockJS
Using RabbitMQ as a multiprotocol message broker
Stacking and consuming tasks with RabbitMQ and AMQP
Securing messages with Spring Session and Redis
Chapter 9: Testing and Troubleshooting
Introduction
Automating Database Migrations with FlyWay
Unit testing with Mockito and Maven Surefire
Integration testing with Cargo, Rest-assured, and Maven failsafe
Injecting Spring Beans into integration tests
Modern application Logging with Log4j2

What You Will Learn

  • Structure your project with Maven and create self-tested, domain-specific deployable web archives
  • Generate templates for a responsive and powerful frontend with AngularJS and Bootstrap
  • Build a high performance stateless RESTful and hypermedia application to support your multiple customer experiences
  • Authenticate over REST with a BASIC authentication scheme and OAuth2; handle roles and permissions
  • Document and publish your REST API using Swagger and Swagger UI
  • Scale your Spring web application
  • Communicate through WebSocket and STOMP messages
  • Provide support to your application and efficiently maintain its business features with a relevant test stack

Authors

Table of Contents

Chapter 1: Setup Routine for an Enterprise Spring Application
Introduction
Installing Eclipse for JEE Developers and Java SE 8
Configuring Eclipse for Java 8, Maven 3, and Tomcat 8
Defining the project structure with Maven
Installing Spring, Spring MVC, and a web structure
Chapter 2: Designing a Microservice Architecture with Spring MVC
Introduction
Configuring a controller with simple URL mapping
Configuring a fallback controller using ViewResolver
Setting up and customizing a responsive single page webdesign with Bootstrap
Displaying a model in the View, using the JSTL
Defining a common WebContentInterceptor
Designing a client-side MVC pattern with AngularJS
Chapter 3: Working with Java Persistence and Entities
Introduction
Configuring the Java Persistence API in Spring
Defining useful EJB3 entities and relationships
Making use of the JPA and Spring Data JPA
Chapter 4: Building a REST API for a Stateless Architecture
Introduction
Binding requests and marshalling responses
Configuring content-negotiation (JSON, XML, and so on)
Adding pagination, filters, and sorting capabilities
Handling exceptions globally
Documenting and exposing an API with Swagger
Chapter 5: Authenticating with Spring MVC
Introduction
Configuring Apache HTTP to proxy your Tomcat(s)
Adapting users and roles to Spring Security
Authenticating over a BASIC scheme
Authenticating with a third-party OAuth2 scheme
Storing credentials in a REST environment
Authorizing on services and controllers
Chapter 6: Implementing HATEOAS
Introduction
Turning DTOs into Spring HATEOAS resources
Building links for a hypermedia-driven API
Choosing a strategy to expose JPA Entities
Retrieving data from a third-party API with OAuth
Chapter 7: Developing CRUD Operations and Validations
Introduction
Extending REST handlers to all HTTP methods
Validating resources using bean validation support
Internationalizing messages and contents for REST
Validating client-side forms with HTML5 AngularJS
Chapter 8: Communicating Through WebSockets and STOMP
Introduction
Streaming social events with STOMP over SockJS
Using RabbitMQ as a multiprotocol message broker
Stacking and consuming tasks with RabbitMQ and AMQP
Securing messages with Spring Session and Redis
Chapter 9: Testing and Troubleshooting
Introduction
Automating Database Migrations with FlyWay
Unit testing with Mockito and Maven Surefire
Integration testing with Cargo, Rest-assured, and Maven failsafe
Injecting Spring Beans into integration tests
Modern application Logging with Log4j2

Book Details

ISBN 139781784396411
Paperback466 pages
Read More

Read More Reviews