Book description
Over 40 recipes for creating cloud-ready Java web applications with Spring MVC
About This Book
- Configure Spring MVC to build logic-less controllers that transparently support the most advanced web techniques
- Build an amazing social and financial application that applies microservices patterns on deployment, self-testability, interoperability, cloud architectures, and scalability
- Fast-paced, practical guide to learn how to set up Spring MVC to produce REST resources and templates as required by the latest front-end best practices
Who This Book Is For
If you are an experienced Java developer, with prior experience in web technologies, and want to step up in your career and stay up-to-date or learn more about Spring Web scalability, this book is for you.
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
In Detail
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.
Style and approach
A comprehensive, recipe-based guide to creating stunning Java apps with Spring MVC as a result of learning and implementing pro-level practices, techniques, and solutions.
Publisher resources
Table of contents
-
Spring MVC Cookbook
- Table of Contents
- Spring MVC Cookbook
- Credits
- About the Author
- About the Reviewer
- www.PacktPub.com
- Preface
-
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
-
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
- 3. Working with Java Persistence and Entities
-
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
-
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
- 6. Implementing HATEOAS
-
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
-
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
- Getting ready
- How to do it…
- How it works...
- There's more…
- See also
-
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
- Index
Product information
- Title: Spring MVC Cookbook
- Author(s):
- Release date: February 2016
- Publisher(s): Packt Publishing
- ISBN: 9781784396411
You might also like
book
Java Coding Problems
Develop your coding skills by exploring Java concepts and techniques such as Strings, Objects and Types, …
video
Practical Python: Learn Python Basics Step by Step - Python 3
Python is one of the most popular programming languages and gives a lot of scope and …
video
Spring MVC With Spring Boot (All Modules) and Project
Enter the world of Spring MVC by learning Spring Data JPA and Spring Security the easy …
book
Modern API Development with Spring and Spring Boot
A developer's guide to designing, testing, and securing production-ready modern APIs with the help of practical …