Skip to content
Ameen Abozaid
JNR-011

Spring Boot

  • 8 Lessons
  • 2 h practice (estimate)
On this page 8 topics

Overview

Topics

  • Starters
  • auto-configuration
  • project structure
  • embedded servers

Learn first

2 h of practice (estimate)

Learning outcomes

  1. Explain starters and how auto-configuration decides what to create (conditions).
  2. Read the conditions evaluation report to see why something was or was not configured.
  3. Override an auto-configured bean.
  4. Describe the embedded server and build an executable JAR.

Lessons

  1. 01What Boot adds to Spring
  2. 02Starters
  3. 03Auto-configuration and conditions
  4. 04Overriding defaults
  5. 05Embedded servers and executable JARs
  6. 06Project structure conventions
  7. 07Demo: reading the conditions evaluation report
  8. 08Demo: overriding Jackson's auto-configuration

Lab and exercises

Lab

JNR-011-LAB1 · Under the hood

Outcomes: 1–4 · Time: ~2 h

  1. Run the Shop API with --debug and save the conditions evaluation report.
  2. Pick three auto-configurations that applied (positive matches) and one that did not (negative match); for each, write the condition that decided it.
  3. Override the default JSON date format (property first, then customizer).
  4. Build the executable JAR and run it with java -jar.

Acceptance: written explanation matches the report; date format changed; JAR runs.

Exercises (assessment: explain the startup sequence of the Shop API)

IDOutcomeTask
JNR-011-EX011Explain in three sentences what a starter and an auto-configuration are and how they differ.
JNR-011-EX021Name the three conditions @ConditionalOnClass, @ConditionalOnMissingBean, @ConditionalOnProperty and give one example of each.
JNR-011-EX032In the report, find why a DataSource was not created in a project without a database starter.
JNR-011-EX043Define your own Clock or ObjectMapper bean and confirm in the report that Boot's default backed off.
JNR-011-EX054Build the JAR, list its contents with jar tf, and find the embedded server library.
JNR-011-EX064Write the startup sequence of the Shop API: main, SpringApplication.run, context creation, scanning, auto-configuration, server start, "Started".
Show solutions
  • EX01 A starter is a dependency bundle; auto-configuration is the code, triggered by what is on the classpath, that creates beans. Starter supplies the libraries; auto-configuration wires them.
  • EX02 Class present (Tomcat classes); missing bean (no user-defined ObjectMapper); property (spring.main.banner-mode, or a feature flag).
  • EX03 Negative match: required classes, or a bean of the needed type, are absent.
  • EX04 The report lists the default bean under negative matches with @ConditionalOnMissingBean found a bean.
  • EX05 jar tf target/*.jar shows BOOT-INF/lib/tomcat-embed-core-*.jar.
  • EX06 main calls run; Boot prepares the environment and creates the context; scanning finds your beans; auto-configuration adds the defaults; the embedded server starts; the app logs "Started".

Quiz

Outcomes: O1 starters and auto-configuration · O2 conditions report · O3 overriding · O4 embedded server and JAR.

A self-check for you: nothing is graded, saved or sent anywhere. Choose an answer, then check it. You can try again as often as you like.

  1. 1A starter is:O1
  2. 2Auto-configuration decides what to create based on:O1
  3. 3@ConditionalOnMissingBean means:O1
  4. 4How do you turn on the conditions evaluation report?O2
  5. 5An auto-configuration appears under "Negative matches". It means:O2
  6. 6The preferred first way to change a Boot default:O3
  7. 7You define your own ObjectMapper bean. Boot's default:O3
  8. 8Blindly excluding auto-configurations is risky because:O3
  9. 9The embedded server is:O4
  10. 10To run the built executable JAR you need:O4

Practical part

Six exercises JNR-011-EX01 to EX06 plus the lab. The assessment is EX06: explaining the Shop API startup sequence. Pass: quiz at least 8/10, the lab explanation matches the report, EX06 correct.

Common mistakes

Treating auto-configuration as magic; excluding auto-configurations blindly.

Assessment

Explain the startup sequence of the Shop API.

Career relevance

Troubleshooting configuration issues in real services.

Type to search levels, phases, modules and lessons.