Skip to content

Latest commit

 

History

History

bootless

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

bootless

A basic Spring Framework application without Spring Boot.

Overview

Why make a Spring application without Spring Boot? For educational purposes of course.

Instructions

Follow these instructions to build and run the example program.

  1. Pre-requisite: Java
    • I used Java 21
  2. Build the program distribution:
    • ./gradlew installDist
  3. Run the program:
    • ./build/install/bootless/bin/bootless
    • Observe the logs. Spring logs some startup information and our own code logs custom messages. Here are snippets of the output.
    • 00:34:51.385 [main] INFO dgroomes.spring_playground.bootless.Main - Wiring up a simple Spring application context
      ...
      00:34:51.462 [main] DEBUG org.springframework.context.annotation.AnnotationConfigApplicationContext - Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4b1c1ea0
      ...
      00:34:51.558 [scheduledExecutorFactoryBean-1] INFO dgroomes.spring_playground.bootless.Beans - Hello, I am a 'Runnable' that was instantiated and executed on a schedule via Spring Framework
      

Wish List

General clean-ups, TODOs and things I wish to implement for this project:

  • DONE (thanks LLMs) Learn the Bean lifecycle better and specifically learn how to shutdown the schedule executor in an idiomatic way
  • DONE (Done in the subproject bootless-web-mvc) Can I configure and start a Spring web server (i.e. SpringMVC) without Spring Boot? I remember looking and could not find a way to do this. I know that it would be rare to ever do this, but I assume it has to be possible and even officially supported because after all, Spring Framework still has legs without Spring Boot.
  • DONE (Ok I learned how to do it but not going to commit it here. I'm not sure I'll ever care about startup time to that degree unless I also wanted to AOT the whole program ala Graal) What if I didn't use component scanning (is that the right word? I want spring to not scan the classpath).
    • In particular, I feel like the following logs show the slowness (of course for this miniscule program the duration is not a problem)
    • 19:20:43.425 [main] DEBUG dgroomes.spring_playground.bootless.Main - Instantiating the application context...
      19:20:43.506 [main] DEBUG org.springframework.context.annotation.ClassPathBeanDefinitionScanner - Identified candidate component class: file
      
    • That's about half the time of the whole initialization. Is that the fixed cost of using an application context? It's fine if it is. Just curious. UPDATE: ok it's a bit faster (81ms vs 50ms (and remember we're in rounding error territory)). I think the remaining fixed cost is just class loading.
    • 19:28:25.686 [main] DEBUG dgroomes.spring_playground.bootless.Main - Instantiating the application context...
      19:28:25.736 [main] DEBUG org.springframework.context.support.GenericApplicationContext - Refreshing org.springframework.context.support.GenericApplicationContext@370736d9
      

Reference