Goals
- Get familiar with Spring and ecosystem
- Learn how to create Maven project for Spring
- Get familiar with Spring Core, Spring JDBC, Spring Data, Spring MVC, Spring Security
- Learn how to test applications based on the Spring Framework
- Learn best practices
What is covered
- Inversion of Control (IoC)
- The Spring Web MVC framework
- Data access with JDBC
- Unit and integration testing
- Transaction management
Prerequisites
References
Technical documentation
Tasks
Spring Core
- Create standalone project
- Create Application Context with XML or Java configuration
- Create basic layers to store and retrieve loans and autowire them together
- Loan Service allows to CRUD loans using Loan Repository
- Loan Repository is a simple in memory list of Loans
- Loan model
- Id (integer)
- Requester full name (string, 128 chars)
- Purpose (string, 255 chars)
- Amount (positive decimal)
- Create Integration Test that checks if CRUD operations are performed correctly
- Localize application
- Use properties placeholder that reads environment / commandline properties
- In the command line store application name that will be displayed in the console when application starts. Remember to create Service for that!
Spring JDBC
- Make Loan Repository using database
- Make datasource using connection properties from commandline properties
Spring Data
- Change Loan Repository to use Spring Data
Spring AOP
- In order to improve logging create logger for input and output data of annotated method.
- The front page is often accessed. Create an aspect, which will cache list of loans for a user, without hitting a repository.
Spring MVC
- Create web project
- Create home page with welcome title.
- Display application name that will be stored in environment variable
- Add menu to home and all new pages, that holds links to:
- Homepage
- List of loans
- Form for new loan request
- Create loan list page
- Display all loans in the grid
- Add action column with delete, edit action
- Create loan request page that:
- Will display new loan request form
- Will validate loan form
- Create REST endpoints for loans
- Stylize page using Bootstrap 3
Spring Security
- Secure application with Spring Security
- Restrict browsing loans only for logged users (USERs and ADMINs)
- Only users with ADMIN role can edit and delete loans
- All users can request for a new loan (GUESTs, USERs, ADMINs)
- Customize login page
- Create registering new users page