Skip to main content
main-content

Über dieses Buch

Master Spring basics and core topics, and share the authors’ insights and real–world experiences with remoting, Hibernate, and EJB. Beyond the basics, you'll learn how to leverage the Spring Framework to build the various tiers and parts of an enterprise Java application: transactions, web and presentation tiers, deployment, and much more. A full sample application allows you to apply many of the technologies and techniques covered in Pro Spring 5 and see how they work together.

This book updates the perennial bestseller with the latest that the new Spring Framework 5 has to offer. Now in its fifth edition, this popular title is by far the most comprehensive and definitive treatment of Spring available. It covers the new functional web framework and interoperability with Java 9.

After reading this definitive book, you'll be armed with the power of Spring to build complex Spring applications, top to bottom.

The agile, lightweight, open-source Spring Framework

continues to be the de facto leading enterprise Java application development framework for today's Java programmers and developers. It works with other leading open-source, agile, and lightweight Java technologies such as Hibernate, Groovy, MyBatis, and more. Spring now works with Java EE and JPA 2 as well.

What You'll Learn

Discover what’s new in Spring Framework 5

Use the Spring Framework with Java 9

Master data access and transactions

Work with the new functional web framework

Create microservices and other web services

Who This Book Is For

Experienced Java and enterprise Java developers and programmers. Some experience with Spring highly recommended.

Inhaltsverzeichnis

Frontmatter

Chapter 1. Introducing Spring

Abstract
As Java developers, our rivers run rife with open source projects, but, like the prospectors, finding a useful project can be time-consuming and arduous.
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 2. Getting Started

Abstract
Often the hardest part of learning to use any new development tool is figuring out where to begin. Typically, this problem is worse when the tool offers as many choices as Spring. Fortunately, getting started with Spring isn’t that hard if you know where to look first.
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 3. Introducing IoC and DI in Spring

Abstract
Practically, dependency injection is a specialized form of IoC, although you will often find that the two terms are used interchangeably. In this chapter, we give you a much more detailed look at IoC and DI, formalizing the relationship between the two concepts and looking in great detail at how Spring fits into the picture.
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 4. Spring Configuration in Detail and Spring Boot

Abstract
In the previous chapter, we presented a detailed look at the concept of inversion of control (IoC) and how it fits into the Spring Framework. However, we have really only scratched the surface of what Spring Core can do. Spring provides a wide array of services that supplement and extend its basic IoC capabilities.
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 5. Introducing Spring AOP

Abstract
Besides dependency injection (DI), another core feature that the Spring Framework offers is support for aspect-oriented programming (AOP). AOP is often referred to as a tool for implementing crosscutting concerns. The term crosscutting concerns refers to logic in an application that cannot be decomposed from the rest of the application and may result in code duplication and tight coupling.
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 6. Spring JDBC Support

Abstract
By now you have seen how easy it is to build a fully Spring-managed application. You have a solid understanding of bean configuration and aspect-oriented programming (AOP).
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 7. Using Hibernate in Spring

Abstract
In the previous chapter, you saw how to use JDBC in Spring applications. However, even though Spring goes a long way toward simplifying JDBC development, you still have a lot of code to write. In this chapter, we cover one of the object-relational mapping (ORM) libraries called Hibernate.
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 8. Data Access in Spring with JPA2

Abstract
In the previous chapter, we discussed how to use Hibernate with Spring when implementing data access logic with the ORM approach.
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 9. Transaction Management

Abstract
Transactions are one of the most critical parts of building a reliable enterprise application. The most common type of transaction is a database operation. In a typical database update operation, a database transaction begins, data is updated, and then the transaction is committed or rolled back, depending on the result of the database operation. However, in many cases, depending on the application requirements and the back-end resources that the application needs to interact with (such as an RDBMS, message-oriented middleware, an ERP system, and so on), transaction management can be much more complicated.
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 10. Validation with Type Conversion and Formatting

Abstract
In an enterprise application, validation is critical. The purpose of validation is to verify that the data being processed fulfills all predefined business requirements as well as ensures the data integrity and usefulness in other layers of the application.
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 11. Task Scheduling

Abstract
Task scheduling is a common feature in enterprise applications. Task scheduling is composed mainly of three parts: the task (which is the piece of business logic needed to run at a specific time or on a regular basis), the trigger (which specifies the condition under which the task should be executed), and the scheduler (which executes the task based on the information from the trigger). Specifically, this chapter covers the following topics
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 12. Using Spring Remoting

Abstract
An enterprise application typically needs to communicate with other applications. Take, for example, a company selling products; when a customer places an order, an order-processing system processes that order and generates a transaction. During order processing, an inquiry is made to the inventory system to check whether the product is in stock. Upon order confirmation, a notification is sent to the fulfillment system to deliver the product to the customer. Finally, the information is sent to the accounting system, an invoice is generated, and the payment is processed.
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 13. Spring Testing

Abstract
When developing applications for enterprise use, testing is an important way to ensure that the completed application performs as expected and fulfills all kinds of requirements (architectural, security, user requirements, and so on). Every time a change is made, you should ensure that the changes that were introduced don’t impact the existing logic. Maintaining an ongoing build and test environment is critical for ensuring high-quality applications. Reproducible tests with high coverage for all your code allow you to deploy new applications and changes to applications with a high level of confidence. In an enterprise development environment, there are many kinds of testing that target each layer within an enterprise application, and each kind of testing has its own characteristics and requirements. In this chapter, we discuss the basic concepts involved in the testing of various application layers, especially in the testing of Spring-powered applications. We also cover the ways in which Spring makes implementing the test cases of various layers easier for developers. Specifically, this chapter covers the following topics
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 14. Scripting Support in Spring

Abstract
In previous chapters, you saw how the Spring Framework can help Java developers create JEE applications. By using the Spring Framework’s DI mechanism and its integration with each layer (via libraries within the Spring Framework’s own modules or via integration with third-party libraries), you can simplify implementing and maintaining business logic.
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 15. Application Monitoring

Abstract
A typical JEE application contains a number of layers and components, such as the presentation layer, service layer, persistence layer, and back-end data source. During the development stage, or after the application had been deployed to the quality assurance (QA) or production environment, you will want to ensure that the application is in a healthy state without any potential problems or bottlenecks.
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 16. Web Applications

Abstract
In an enterprise application, the presentation layer critically affects the level of acceptance that users give the application. The presentation layer is the front door into your application. It lets users perform business functions provided by the application, as well as presents a view of the information that is being maintained by the application. How the user interface performs greatly contributes to the success of the application.
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 17. WebSocket

Abstract
Traditionally, web applications have utilized the standard request/response HTTP functionality to provide communication between the client and server. As the Web has evolved, more interactive abilities have been required, some of which demand push/pull or real-time updates from the server. Over time, various methods have been implemented, such as continuous polling, long polling, and Comet. Each has its pros and cons, and the WebSocket protocol is an attempt to learn from those needs and deficiencies, creating a simpler and more robust way to build interactive applications. The HTML5 WebSocket specification defines an API that enables web pages to use the WebSocket protocol for two-way communication with a remote host.
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Chapter 18. Spring Projects: Batch, Integration, XD, and More

Abstract
This chapter presents a high-level overview of a few projects that are part of the Spring portfolio, notably Spring Batch, Integration, XD, and a few notable features added in Spring Framework version 5. This chapter is not intended to cover each project in detail but to provide just enough information and a sample to get you started. The Spring portfolio contains many more projects than the ones discussed in this chapter, but we feel the ones presented here are widely used, and some are new and upcoming projects. You can view the full list of Spring projects at http://spring.io/projects . This chapter covers the following topics
Iuliana Cosmina, Rob Harrop, Chris Schaefer, Clarence Ho

Backmatter

Weitere Informationen

Premium Partner

    Bildnachweise