Video summary

#8 Spring without Boot

Main summary

Key takeaways

Educational

Main ideas / lessons

  • The video explains how to build and run a plain Spring Framework project without Spring Boot, and what Spring does “behind the scenes” when it creates objects.
  • It motivates why you might avoid Spring Boot:
    • You have no choice (company/project constraints).
    • You want to understand how Spring processes configuration and what happens internally.
  • Spring Boot usually hides much of the configuration (annotations + auto-setup). Without Boot, you must do more manual setup, especially for:
    • Adding the right Spring dependencies
    • Creating the container (ApplicationContext / IOC container)
    • Providing configuration (initially XML)

Step-by-step methodology shown (detailed)

1) Create a non-Spring-Boot project template

  • In an IDE, create a new Maven project:
    • Project name: “demo spring”
    • Packaging/download location: any
    • JDK: choose the local JDK version (example used: Java 21)
  • Select a Maven archetype:
    • Uses Maven Archetype (from internal catalog)
    • Chooses Quick Start / a basic web app-type template (the instructor mentions Quick Start and web app options)

2) Add Spring Framework dependencies (since Spring isn’t included yet)

  • After creating the project, the instructor notes:
    • There is no Spring feature by default (no Spring dependency)
    • No Spring Boot-style auto-configuration exists
  • Add dependency by searching Maven Repository for:
    • spring-context (example versions discussed: avoid vulnerable versions like 5.3, use 6.1.6 in the demo)
  • In IntelliJ, reload Maven changes:
    • Click “Load Maven changes”

3) Reuse a plain class from the Spring Boot example

  • Copy a simple class (example: Dev with a build() method that prints something like “working on the awesome project”).
  • Initially run it without Spring to confirm the project works:
    • Create an object directly:
      • Dev obj = new Dev();
    • Call:
      • obj.build();

4) Understand that Spring objects come from the IOC container

  • The conceptual flow:
    • Spring creates objects inside the container (IOC container).
    • To use Spring’s container, you need an ApplicationContext.
  • Problem encountered:
    • Trying to use component / annotation-based creation won’t work yet because Spring isn’t configured the way component scanning expects (and the Spring framework configuration hasn’t been set up).

5) Create an ApplicationContext (container creation)

  • Add Spring’s ApplicationContext usage:
    • ApplicationContext context = ...
  • Since ApplicationContext is an interface, use an implementation that starts with XML configuration:
    • ClassPathXmlApplicationContext
  • Specify the XML file name (example):
    • spring.xml

6) Create the required XML configuration file

  • Error explained:
    • Spring can’t find the XML file:
      • it searches under classpath resource locations.
  • Fix:
    • Ensure a resources folder exists in the project.
    • Add spring.xml inside it:
      • src/main/resources/spring.xml
  • Next expected behavior:
    • If spring.xml is empty, the next error is parsing-related (example shown: “premature end of file”)
  • The instructor notes the details of XML configuration will be covered in the next video.

Speakers / sources featured (at end)

  • Speaker: Zin (as stated in the subtitles: “my name is Zin”)
  • Sources referenced:
    • Maven Repository (for finding Spring dependencies)
    • IDE archetype/template catalog (Maven archetypes: internal / Maven Central mentioned)
    • IntelliJ IDEA / Eclipse (used as examples for creating projects and loading Maven changes)

Original video