Mastering the Spring Framework and Hibernate
Contact us to book this course
Curriculum
Java
Delivery methods
On-Site, Virtual
Duration
5 days
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
Prerequisites
Knowledge and understanding of Java to the level of Course 430 (Essential Java) is required.
Course outline
- 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
- 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
- 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
- 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
- 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
- About REST
- JSON
- JAX-RS
- Spring Support for REST
- Deploying a RESTful Service in a Docker Container
- Limitations of JDBC
- How Spring Improves on JDBC
- JdbcTemplate
- Queries and Callbacks
- 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
- Securing a Web Application Declaratively
- Intercepting Web Requests
- Authenticating Against a Database
- Role-Based Authentication
- Pattern-Based Authorization
- Exercise: Securing a Web Application
- 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
- 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