Course 445:
Mastering the Spring Framework and Hibernate

(5 days)


Course Description

Building on dependency injection and aspect-oriented programming (AOP), the Spring Framework can dramatically simplify the development of all layers of a Java enterprise application including those involving relational and NoSQL databases, RESTful web services, web applications, and transaction management.

This hands-on course presents developers with best practices for software development with the Spring Framework. Attendees will perform hands-on exercises, building a microservice application deployed in Docker containers as they learn the concepts.

Learning Objectives

  • Best practices in using Spring to implement a Microservice Architecture (MSA)
  • Injecting dependencies using the Spring bean factory
  • Unit and Integration Testing with Spring
  • Simplifying database access
  • Aspect-oriented programming with Spring
  • Persisting business objects using JPA
  • Implementing a presentation tier with Spring MVC
  • Creating RESTful Web Services
  • Containerize an MSA application with Docker and Docker Compose

Who Should Attend

  • Java programmers involved in developing enterprise applications


Knowledge and understanding of Java to the level of Course 430 (Essential Java) is required.

Course Outline

Chapter 1: Motivating the Spring Framework

  • Evolution of Java Enterprise Systems, Leading to Spring
  • Microservice Architecture (MSA)
  • Overview of Eclipse, Maven, and Git
  • Introduction to Using Docker Containers
  • Exercise: Exploring the Case Study
  • Unit Testing with JUnit
  • Exercise: Unit Testing

 Chapter 2: Inversion of Control Using Spring

  • Designing to Interfaces
  • Factory Design Pattern
  • Exercise: Implementing a Factory
  • Inversion of Control
  • Spring’s Core IoC Container
  • BeanFactory
  • XML Configuration
  • Exercise: Spring as a Factory
  • ApplicationContext
  • Registering a Shutdown Hook
  • Exercise: Bean Destroy

Chapter 3: Dependency Injection Using Spring

  • Dependency Injection
  • Injecting Values
  • Try It Now: Dependency Injection
  • PropertyEditor
  • Try It Now: Property Editor
  • Invoking Constructor
  • Constructor or Setter?
  • Instantiating Beans Using Factory Methods
  • Exercise: Applying Dependency Injection

 Chapter 4: Spring Web MVC

  • Model 2 Architecture
  • Spring’s Implementation of MVC
  • Maintaining User State
  • Session Façade
  • Exercise: Implementing a SessionFacade
  • DispatcherServlet
  • Convention over Configuration
  • Controllers and Mappings
  • Reusing Bean Definitions
  • Resolving Views
  • Configuring Spring Actions as Spring Beans
  • Injecting Spring-Controlled Objects
  • Exercise: Implementing Web Application with Spring MVC

 Chapter 5: Advanced Spring Concepts

  • Autowiring
  • Try It Now: Autowiring
  • Checking Dependencies
  • Factory Aware, Bean Postprocessing, Lookup Method Injection
  • Try It Now: Bean Factory Aware
  • Try It Now: Lookup Method Injection
  • Aspect-Oriented Programming
  • ProxyFactoryBean
  • Intercepting Methods
  • Applying Advice
  • Try It Now: Aspect-Oriented Programming
  • Pointcuts
  • Transactions are ACID
  • Programming for Transactions
  • Declarative Transactions in Spring
  • Try It Now: Declarative Transactions to Prevent Accidental Updates

 Chapter 6: RESTful Web Services with Spring

  • About REST
  • JSON
  • JAX-RS
  • Spring Support for REST
  • Deploying a RESTful Service in a Docker Container

Chapter 7: Database Access

  • Limitations of JDBC
  • How Spring Improves on JDBC
  • JdbcTemplate
  • Queries and Callbacks

Chapter 8: Spring JPA

  • Introducing the Java Persistence API
  • JPA Query Language (JPQL)
  • Try It Now: JPA without Spring
  • Introducing Spring JPA
  • Exercise: Using Spring JPA
  • Persistence Requirements
  • Implementing equals()
  • Entities and Value Types
  • Mapping Collections and Associations
  • One-to-many, Many-to-One, One-to-One, Many-to-Many
  • Generating IDs
  • Mapping Inheritance Hierarchies
  • Choosing the Inheritance Mapping Strategy
  • Exercise: Using Spring JPA to Persist an Inheritance Hierarchy
  • Short-Lived and Long-Lived Transactions
  • Optimistic Transactions with Version
  • Pessimistic Transactions with Detached Objects

 Chapter 9: The Spring Security Framework

  • Securing a Web Application Declaratively
  • Intercepting Web Requests
  • Authenticating Against a Database
  • Role-Based Authentication
  • Pattern-Based Authorization
  • Exercise: Securing a Web Application

 Chapter 10: Spring Best Practices

  • Good OO and Distributed Design Practices
  • Testing with Wired Up Beans
  • Testing with Mock Beans, Pros, and Cons
  • Try It Now: Testing a Session Façade with Mock Dependencies
  • Maintainable Bean Definitions
  • When to Inject and When Not to Inject
  • Exception Best Practices in Spring
  • Thread-safety in Spring Beans

Chapter 11 [Optional]: Test-Driven Development

  • What to Test
  • Forms of Software Testing
  • Unit Testing with JUnit
  • Testing Exception Throwing
  • Simplifying Tests with JUnit4 Annotations
  • Integration and Functionality Testing
  • Testing Container-Managed Components
  • Mock Objects
  • Testing Spring Services
  • Best Practices to Support Mock Objects
  • Spring Support for Mock Objects

Please Contact Your ROI Representative to Discuss Course Tailoring!