Skip to content

Frendzel/sda-ldz31

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Workshops plan

Workshops 1 - 09.01.2022 - [Intro] âś”

Workshops 2 - 22.01.2022 - [Beginner] âś”

Workshops 3 - 23.01.2022 - [Advanced] âś”

Workshops 4 - 29.01.2022 - [Advanced] âś”

Workshops 5 - 05.02.2022 - [Advanced] âś”

Workshops 6 - 06.02.2022 - [Extra] âś”

Modules

  • BASIC WEBAPP
  • SPRING BOOT AOP
  • SPRING BOOT BATCH
  • SPRING BOOT CACHE
  • SPRING BOOT THYMELEAF
  • SPRING BOOT JDBC-TEMPLATE
  • SPRING BOOT JMS
  • SPRING BOOT JPA
  • SPRING BOOT MONGODB
  • SPRING BOOT R `EST
  • SPRING BOOT SCHEDULER
  • SPRING BOOT TRANSACTIONS
  • SPRING BOOT VALIDATOR

TO COVER:

  • Spring basics
  • Spring core
  • Spring MVC (JSP/Thymeleaf)
  • Spring Boot
  • Spring Data
  • Spring Security
  • Webservices
  • Angular/React integration [optional]

Intro

Let's start!

  1. Generate Sample Spring Project ✔️
  2. Import to IDE ✔️
  3. Try to build & Try to run ✔️
  4. Check exposed method via browser ✔️
  5. Try to expose actuator ✔️
  6. Validate healthcheck ❌
  7. Add CommandLineRunner ✔️
  8. Try to print all beans ✔️
  9. Change log level for some packages âś”
  10. Define log level for our package âś”
  11. Write simple junit test âś”
  12. Expose Greeting controller method + write test, for example mockMvc âś”
  13. Define DAO layer with 2 database types (H2, HARDCODED) chosen via factory ❌
  14. Pass usage of dedicated db via property file âś”
  15. Add dependency like lombok + define loggers âś”
  16. Add scheduler for simple logging âś”
  17. Chuck Norris Jokes! Log them in scheduler from website âś”
  18. Add serialization/deserialization âś”
  19. Implement Mapstruct mapping between dao & dto âś”
  20. Add proper layers implementation âś”
  21. Change properties file to yml file ❌
  22. Different ways of autowiring beans âś”
  23. Sample DB usage (List of Jokes?) âś”
  24. Service Layer (RestTemplate, maybe HttpClient) âś”
  25. Tests for service layer âś”
  26. Chuck Norris Jokes Collector controller implementation âś”
    1. Usage of: http://api.icndb.com API âś”
    2. REST GET âś”
    3. REST POST âś”
    4. REST PUT ❌
    5. REST DELETE ❌
  27. Load json data from file and use in test to compare values ❌
  28. Save data to file in service ❌
  29. Hexagonal architecture proposal for application (separated module) ❌
  30. Validation request (POST) âś”
  31. Deployment to Cloud: ❌
    1. https://www.heroku.com/
  32. Repository âś”
  33. Profiles on repository (Mock DB + H2) âś”
    1. Define different configurations for repos âś”
  34. Basic tests âś”
  35. H2 DB schema via sql file âś”
  36. Connect with Service âś”
  37. Connect withDedicatedController âś”
  38. Pass custom properties via @Value annotation âś”
  39. Mapstruct usage âś”
  40. Manual mapper âś”
  41. Implement Scheduler âś”
    1. save random jokes to DB âś”
  42. Aspects âś” 2. LogExecutionTimeAspect âś” 3. LogBefore some method âś” 4. Our own annotation âś”
  43. Validation (@Valid) âś”
  44. ConstraintViolation âś”
  45. JMS Listener + Producer âś”
  46. Thymeleaf + Form âś”
  47. Mapstruct âś”
    1. Add to project - do mapper âś”
  48. Validation Request/Response âś”
  49. H2 Added âś”
  50. NoSQL - presentation âś”

LAST CLASSES:

  • Reminder what we did (CSV Printer)
  • BindingResult support in forms âś”
  • Reflection
  • SpringSecurity - how to turn on
  • NoSQL - MongoDB Workshops ** Cloud setup âś”
  • Cache + Cacheable
  • jdbcTemplate autowired + execute ** pure insert ** pure select
  • Transactional
  • Add WebJars
  1. Add webjar bootstrap:
<!-- https://mvnrepository.com/artifact/org.webjars/bootstrap -->
<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>bootstrap</artifactId>
    <version>5.1.3</version>
</dependency>

3 layers app

Sample controllers âś”

Sample DB with repo for H2

Generate sample Spring Boot App

Chuck Norris Jokes collector

Rest API for this

@Cacheable

@Async

Validations

3 layers app

Transactions

Mapstruct to use mapping between DAO and DTO

@Scheduler

Save jokes on MongoDB App using MongoClient

make json from object

Turn On H2, use JDBC repository to save data to the sql DB

using ActiveMQ

tests, tests, tests!

unit

integration

mockMvc

cucumber *** -> extra

@Aspect to calculate invocation time

Write extra tools to export data to the PDF, CSV, EXCEL formats

Use testcontainers to avoid SQL database *** -> extra

Tasks

Task 1 - REST-SERVICE

Rest Controller with get method exposed on /greeting address + parameter support

deps:

  • spring-boot-starter-web
  • spring-boot-starter-test
  • com.jayway.jsonpath

Task 2 - SPRING BOOT

Hello Controller + prompting in console all beans definition

deps:

  • spring-boot-starter-web
  • spring-boot-starter-actuator
  • spring-boot-starter-test
  • spring-test

Task 3 - JDBC-TEMPLATE

use JDBCTemplate to:

  • drop table if exists
  • create tables
  • use select
  • batch insert sample
  • map data between object and db

deps:

  • spring-boot-starter-jdbc

Task 4 - JPA

Save entity via repository / spring data by manager in dao layer

deps:

  • spring-boot-starter-data-jpa
  • spring-data
  • com.h2database

Task 5 - SCHEDULER

Scheduler + cron expressions

deps: spring-context

Task 6 - TRANSACTIONS

Simple app + @Transactional usage

deps:

  • com.h2database

Task 7 - ASYNC

Async methods + restTemplate usage

deps:

  • spring-web

Task 8 - BATCH

Based on: http://malsolo.com/blog4java/?p=260

we will write app which will import data from csv and save them in db using jobs

Usage:

  • JdbcBatchItemWriter
  • ItemProcessor
  • FlatFileItemReader
  • jdbcTemplate
  • JobExecutionListenerSupport

deps:

  • spring-boot-starter-batch

Task 9 - CACHE

Simple task to add @Cacheable mechanism

deps:

  • spring-boot-starter-cache

Task 10 - VALIDATOR

Write simple validator extending class WebMvcConfigureAdapter + integration tests + annotations javax.validation.constraints

deps:

  • spring-boot-starter-thymeleaf
  • hibernate-validator

Task 11 - MongoDB Connector to MongoDB

Task 12 - JMS

Refactor architecture to use JMS

deps:

  • spring-boot-starter-activemq
  • activemq-broker
  • jackson-databind

Task 13 - FILE-UPLOADER

File Uploader which will:

  • download file chosen via form
  • list downloaded files
  • download file sent by user
  • delete chosen files

deps:

  • spring-boot-starter-thymeleaf

Theory

Why do we even need Spring -> https://www.youtube.com/watch?v=ySXlsZDJMgc

IoC

Dependency Injections

Annotations vs Xml

Configuration

ApplicationContext

Beans

Component etc.

Autowired

Polymorphism in Spring

More Theory

DDD

TDD

BDD

Tests categories

Implementation

Generate sample Spring Boot App

Chuck Norris Jokes collector

Rest API for this

@Cacheable

@Async

Validations

3 layers app

Transactions

Mapstruct to use mapping between DAO and DTO

@Scheduler

Save jokes on MongoDB App using MongoClient

make json from object

Turn On H2, use JDBC repository to save data to the sql DB

using ActiveMQ

tests, tests, tests!

unit

integration

mockMvc

cucumber *** -> extra

@Aspect to calculate invocation time

Write extra tools to export data to the PDF, CSV, EXCEL formats

Use testcontainers to avoid SQL database *** -> extra

DataFaker to generate many fake data for reports: https://jworks.io/datafaker-an-alternative-to-production-data/

Architecture

3 layers

how to test architecture -> https://www.archunit.org/

Add JMS usage to architecture (Producer, Consumer)

Different implementations (queue vs topic) and usage for consumed messages: save to DB, save to PDF, save to excel, send via mail.

Alternatives:

Picocontainer

Micronaut

Dagger2

Getting Started

Reference Documentation

For further reference, please consider the following sections:

Guides

The following guides illustrate how to use some features concretely:

Group work ideas:

Spring Mail

Jokes rank app.

Sending mails with jokes.

Exporting data to dedicated format (PDF, EXCEL, CSV)

Implementing frontend (thymeleaf can be used)

About

Spring workshops

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published