Application startup and lifecycle
17 questions in 6 subtopics.
SpringApplication.run
Describe whatSpringApplication.run does from the call in main until the application is ready.How do you customise startup without changing application.yml, for example setting a default profile, adding a listener and disabling the banner? Show code using SpringApplication or SpringApplicationBuilder.Startup time mattered little when apps were deployed a few times a year, and much more with containers and autoscaling. How has this changed the way you would choose a Java framework and runtime for the next five years?ApplicationRunner and CommandLineRunner
What is the difference betweenApplicationRunner and CommandLineRunner, when are they called, and what happens if one throws an exception?A runner warms a cache by loading 2 million rows at startup. Kubernetes kills the pod during rollouts because it is not ready in time. What options do you have?Many services run database migrations, cache warming and remote registration in runners at startup, and rollouts are slow and fragile. What would you change at platform level?Application events during startup
List the mainSpringApplication events in the order they are published during a successful startup of a web application.A team publishes 'service started' to a registry in a ContextRefreshedEvent listener. In tests and in a parent-child context setup the message is sent twice, and sometimes before the server accepts requests. Why, and what should they use?Failure analyzers
Startup fails with a message under 'APPLICATION FAILED TO START' saying the port 8080 is already in use, followed by an 'Action' section. What produced this message, and how would you resolve the issue?Write aFailureAnalyzer for a custom LicenseMissingException and explain how it is registered.Your platform wants every service to fail fast with clear messages for common misconfigurations such as missing credentials or wrong URLs. How would you build this into the platform?Lazy initialization
What doesspring.main.lazy-initialization=true do, and what are its downsides?A team enables lazy initialization in production to cut startup from 40 to 15 seconds. A week later a misconfigured bean causes errors for the first user of a feature. What would you recommend?Lazy initialization, AOT and other startup optimisations each change when errors appear. What long-term principle would you set for when configuration and wiring errors must surface?Startup time analysis
How would you find which beans make a Boot service take 60 seconds to start?Your company runs 300 Spring Boot services on Kubernetes and autoscaling is slow because pods take 45 seconds to be ready. What fleet-wide options would you evaluate?Over the next years, startup time will affect your cloud costs through autoscaling and scale-to-zero. How would you balance investment in JVM startup techniques against simply running more always-on instances?No question matches these choices.