Course Overview
This in-depth, advanced workshop using Spring will present developers with best practices for software development, as well as tips and techniques for working with the tools and technologies within their specific environment
During the course you will get to know Core Spring, Spring Testing, Spring JDBC, Spring Integration with Hibernate/JPA, Spring RESTful services with Spring MVC and Spring Boot.
Course Prerequisites
To get the greatest benefit from this course you should be an experienced Java Developer.
Outline
Here's what we'll be covering through this course:
Core Spring
Introduction
- Introduction to Spring
- Spring in a historical context
- Introduction to dependency injection and inversion of control (IOC)
- Overview of Spring modules
- Setting up Spring projects with Gradle and maven
Inversion of Control
In this section, we delve into the core of Spring: its Inversion of Control (IoC) container. We include coverage of XML configuration because it greatly aids in understanding the functionality of the IoC container. While XML configuration might seem outdated, we keep its use to a minimum, focusing only on what is necessary for educational purposes.
- Spring configuration using XML
- Defining and configuring beans in XML
- Java-based Spring configuration (
@Configuration
) - Understanding the Application Context and related interfaces
- Initialising an application
- Life-cycle callbacks (init, destroy)
- Defining bean creation (constructor params, factory methods)
- Understand bean scopes
- Property and constructor injection
- Injecting beans and values
- Defining lists, maps, properties, … in the spring configuration
- Bean configuration inheritance
- Externalising configuration with property files using Property Placeholders
- Using Profiles
Annotation-driven
- Enabling and using annotation driven configuration
- Overview of Spring, JSR250 and JSR330 annotations
- Dependency inject by type (
@Autowired
/@Inject
) and by value (@Resource
) - Using the
@Primary
annotation - Using Spring Qualifiers
- Using JSR330 Qualifiers
- Component scanning
- Using stereotype annotations
- Using other techniques for scanning (regex, …)
- Fine tuning scanning
Java configuration in Depth
- Using
@Configuration
and@Bean
- Configure beans (names, Life-cycle methods, scope)
- bean references in the configuration
- Injecting beans into the configuration
- Enabling component scanning
- Using
@Import
- Obtaining the
AnnotationConfigApplicationContext
I18 and more
- Using Factory Beans
- Registering Component Editors
- Internationalisation
Spring Test Framework
Here we merely introduce the Spring Test Framework. Concepts such as database integration tests, transactional tests, mocks, testing web mvc application are explained in their respective session.
- Introduction to Spring Testing
- Using it with junit 5
- Loading the context configuration using
@ContextConfiguration
- Using Dependency Injection for your test fixture
- Using profiles during testing
- Use other spring test annotations (
@Timed
,@Repeat
,@DirtiesContext
) - Replacing beans with mocks
Spring data access
Introduction
- Understand the module's architecture
- Understand its features
- Define Datasources (JNDI, DBCP, C3P0, HikariCP)
- Introduce repository classes
- Introduction to template classes
- Using
DaoSupport
- Understand Spring's consistent exception translation for repositories
- Managing Transactions
- Programmatic and Declarative transaction management
- List various platform transaction managers (DataSource, Jta, Jpa, …)
- Understand the seven transaction attributes
- Setting transaction isolation levels
- Managing transaction time-outs
- Using Spring Test for database integration tests
- Executing sql scripts using
@Sql
during testing - Using Flyway/Liquibase for database migrations
- Using TestContainers with Spring
JDBC
- Using templates (
JdbcTemplate
/NamedParameterJdbcTemplate
) - Using the Jdbc Client fluent-API
- query and update the database using templates
- Using different parameters sources
- Use different result mapping techniques
- Query for single results
- Query for multiple* results
- Mapping to beans/records
- Working with generated keys
- Working with exceptions
- Using jdbc classes such as
SimpleJdbcInsert
- Introduce RDBMS Objects such as
SqlUpdate
ORM and Persistent Frameworks
- Introduce Spring's JPA support
- Using the
LocalContainerEntityManagerFactoryBean
(and alternatives) - Configuring the transaction manager for JPA
- Using the
SessionFactory
in your repositories - List various ways to manage JPAs entity managers
- Introduction to MyBatis
- Using MyBatis mappers in a Spring application
Spring Cache
- Understand the role of caching
- Discuss various caching techniques and their configuration (heap, off-heap, disk, cluster)
- Applying caching to your application using annotations (Spring and JSR-107)
- Best practices for caching
Spring Boot
- Introduce the ideas and architecture behind SpringBoot
- Discuss various starters (Spring Initializr)
- Setting up a Gradle project for spring boot
- Use the spring boot cli (command line interface)
- Configure a SpringBoot application
- Using yaml configuration for datasources
- Configure for logging
- List other key configuration properties
- Setting up your own properties
- Bootstrap the SpringBoot application
- Using Spring Boot in Kubernetes
- Adding metric endpoints and integrate with prometheus/grafana
Spring MVC
Introduction
- Introduce the Spring MVC architecture
- Discuss Spring MVC' features
- Introduce the DispatchServlet
- Configure Spring MVC using Java configuration (Servlet Environment)
- Configure Spring MVC inside a Spring Boot application
- Introduce controllers and RequestMapping
- Map URIs and HTTP methods
- Handle request parameters
- Handle http headers
- List the possible return types of handler methods
- Overview of Handling exceptions
- Using the @ControllerAdvice
Testing
- Introduction to Testing Spring MVC Applications
- Mocking Spring MVC
- Understand how to use the RequestBuilder
- Supply parameters, mime-types, headers, cookies, …
- Setup expectations with ResultMatcher
- Using jsonPath to state expectations on returned json data
Restful Services with Spring
Introduction
- Discuss the architecture of Restful Services
- Best practices for Restful Services (correct URLs, methods, return codes, documentation, …)
- Creating ResultController implementations
- More on URL Patterns mapping (path variables, regex)
- Handle mime-types
- Using HttpEntity in handler methods
- Validating data using jsr303
Jackson
- Introduction to Jackson
- Mapping pojos and records to json/xml/protobuf etc.
- Use Jackson annotations
- Mapping null, Optional.none, and empty strings values
- Introduce Jacksons Views
- Discuss various plugins for data types (most notably jdk8 and jsr310)
- Same for data formats (xml, protobuf, avro, …)
- Configuring Jackson with Spring
- Configure Spring's content negotiation
Spring Security
- Architectural overview of Spring Security
- Authentication and Authorisation with Spring
- Introduce the UserDetailsService
- Integrate with LDAP, Database realms, JAAS, …
- Basic configuration
- Introduce the HttpSecurity DSL
- URL-based authentication
- Introduce the AuthenticationManagerBuilder DSL
- Logging in and logging out (form-based, basic, etc.)
- Building login forms (HTML/React/…/Thymeleaf)
- Adding remember-me to login forms
- Discuss authentication for RESTful services
- Use Method level security
Attack Prevention
- Understand the default protections (Session Fixation, X-XSS Protection, clickjacking)
- CSRF (Cross-Site Request Forgery) attack prevention
- Understand CORS (Cross-origin resource sharing)
- Correctly configure CORS
OAuth2 and OIDC
- Understand OAuth2 and OpenID Connect (OIDC)
- Using JWT (JSON Web Token)
- Use OIDC for web authentication
As you can see from the above course description, this is a densely layered course that has been balanced to give developers valuable insight and the knowledge necessary for Spring.