Spring Boot
The opinionated layer on top of Spring: auto-configuration, starters, externalized configuration, the SpringApplication lifecycle, embedded servers and packaging. Interviewers ask about Boot to find out whether you can explain its conventions or merely rely on them.
part ofSpring Frameworkoverview, primer and where to startread it →on this pageshowhide
explore
- Auto-Configuration25 questions
- @EnableAutoConfiguration & the imports file5 questions
- The @Conditional family5 questions
- Auto-configuration ordering5 questions
- Writing custom auto-configuration5 questions
- Debugging condition evaluation5 questions
- Starters & Dependency Management20 questions
- spring-boot-starter-* aggregation5 questions
- spring-boot-starter-parent5 questions
- The dependency BOM5 questions
- Overriding managed versions5 questions
- Externalized Configuration & Profiles35 questions
- Property sources & precedence5 questions
- @ConfigurationProperties & relaxed binding5 questions
- Validating bound config5 questions
- Spring profiles5 questions
- Config import, trees & secrets5 questions
- EnvironmentPostProcessor SPI5 questions
- Configuration property metadata5 questions
- SpringApplication & Lifecycle24 questions
- SpringApplication & builder5 questions
- ApplicationRunner & CommandLineRunner5 questions
- Application events & listeners5 questions
- Banner, lazy init & graceful shutdown4 questions
- FailureAnalyzer diagnostics5 questions
- Embedded Servers21 questions
- Server selection5 questions
- Server tuning properties5 questions
- WebServerFactoryCustomizer5 questions
- TLS on the embedded server6 questions
- Packaging, Build Plugins & DevTools30 questions
- Executable fat jar layout5 questions
- Layered jars5 questions
- Boot Maven & Gradle plugins5 questions
- OCI images via buildpacks5 questions
- Spring Boot DevTools5 questions
- Class Data Sharing for startup5 questions
questions
155 · 6 sectionsWhat are @ConditionalOnClass and @ConditionalOnMissingClass, and why does Spring Boot auto-configuration rely on them?
basics
~10 s@ConditionalOnClass makes a bean/config load only if a named class is on the classpath; @ConditionalOnMissingClass only if it's absent. Boot uses them so auto-config activates just when the relevant library is present.
What is a custom auto-configuration in Spring Boot, and how do you register it so Spring Boot picks it up automatically?
basics
~10 sA configuration class annotated with @AutoConfiguration that defines @Bean methods. You register it by listing its full class name in the file META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports so Spring Boot loads it on startup.
What is @EnableAutoConfiguration and how does it end up on your application?
basics
~10 s@EnableAutoConfiguration tells Spring Boot to automatically configure beans based on what's on the classpath. You rarely write it directly because @SpringBootApplication already includes it.
Explain @ConditionalOnProperty: its attributes (prefix, name, havingValue, matchIfMissing) and exactly when it matches.
basics
~20 s@ConditionalOnProperty enables config based on a configuration property. It matches when the property (prefix + name) equals havingValue. matchIfMissing=true makes it match even when the property is absent, so a feature can be on by default.
Why do @Bean methods in an auto-configuration almost always use @ConditionalOnMissingBean, and how do the conditional guards let a library back off?
basics
~20 s@ConditionalOnMissingBean means 'only create this bean if the application hasn't already defined one.' It lets the library provide a sensible default while letting the app override it just by declaring its own bean of that type.
What is the spring-boot-dependencies BOM and what problem does it solve?
basics
~10 sspring-boot-dependencies is a BOM (Bill of Materials): a special POM listing tested, compatible versions of Spring and third-party libraries. Import it so you declare dependencies without versions and get a consistent, curated version set.
What is spring-boot-starter-parent and why do Spring Boot projects use it as their Maven parent?
basics
~20 sIt is a special Maven parent POM you inherit from. It sets sensible defaults for you: dependency versions, a Java version, UTF-8 encoding, and it configures the plugin that builds a runnable Spring Boot jar — so you write far less pom.xml.
What is a Spring Boot starter, and what problem does it solve?
basics
~20 sA starter is one dependency coordinate that pulls in a curated, version-aligned set of libraries for a feature. Example: spring-boot-starter-web adds Spring MVC, embedded Tomcat, and Jackson together, so you declare one line instead of hand-picking and version-matching many jars.
In a Maven project that uses spring-boot-starter-parent, how do you override the version of a dependency that Spring Boot manages for you?
basics
~10 sRedefine the version property in your own <properties> block. Spring Boot's parent POM sets properties like jackson-bom.version; declaring the same property in your pom.xml overrides the managed version everywhere it's used.
In Maven, how do you use the Spring Boot managed versions without inheriting spring-boot-starter-parent?
basics
~10 sImport the BOM in <dependencyManagement> with type 'pom' and <scope>import</scope>. That pulls in spring-boot-dependencies' managed versions without making the Boot parent your project's parent.
What is @ConfigurationProperties and how does it differ from @Value?
basics
~10 s@ConfigurationProperties binds a whole group of external properties (from application.yml/properties/env) onto the fields of a POJO in a type-safe way. @Value injects a single property value into one field using a placeholder expression.
What does the `spring.config.import` property do, and what is the effect of the `optional:` prefix?
basics
~10 sspring.config.import tells Spring Boot to pull in extra config from another location (a file, config tree, etc.) during startup. optional: means: if that location is missing, don't fail — just skip it.
What is the spring-boot-configuration-processor, and what does adding it to your build produce?
basics
~10 sIt is a compile-time annotation processor. When you add it as a dependency, it scans your @ConfigurationProperties classes during compilation and generates META-INF/spring-configuration-metadata.json, which IDEs read to give auto-completion and docs for your properties.
What is a Spring profile and how do you activate one?
basics
~10 sA profile is a named group of beans and config that is only active in certain environments (like dev or prod). You turn it on with the property spring.profiles.active, e.g. spring.profiles.active=dev.
In Spring Boot, if the same property (say server.port) is set in application.properties AND passed as a command-line argument, which value wins and why?
basics
~10 sThe command-line argument wins. Spring Boot reads config from many places (property sources). When a key exists in several, the higher-priority source overrides the others, and command-line arguments outrank application.properties.
What is ApplicationReadyEvent in Spring Boot and when should you run code on it?
basics
~20 sApplicationReadyEvent fires when the application has fully started — the context is refreshed and all runners have finished — so it is safe to say the app is ready to serve requests. Use it for startup work that needs a fully live app.
What are CommandLineRunner and ApplicationRunner in Spring Boot, and when do they run?
basics
~10 sThey are interfaces with a single run() method. Spring Boot calls every such bean once at startup, after the application context is fully built, so you can run one-off initialization code.
What does SpringApplication.run(...) do when a Spring Boot application starts?
basics
~10 sSpringApplication.run() bootstraps the app: it creates and configures the Spring ApplicationContext, runs auto-configuration, starts any embedded web server, and returns the running context. It's the one line called from main().
What is the difference between CommandLineRunner and ApplicationRunner?
basics
~10 sBoth run once at startup. CommandLineRunner.run receives the raw String[] arguments. ApplicationRunner.run receives an ApplicationArguments object that has already parsed those strings into --option flags and plain (non-option) arguments.
How does Spring Boot decide whether an app is SERVLET, REACTIVE, or NONE, and how do you override it?
basics
~20 sBoot inspects the classpath. If Spring MVC (servlet) classes are present it picks SERVLET; if only WebFlux is present it picks REACTIVE; if no web classes are present it picks NONE. Override with setWebApplicationType() or spring.main.web-application-type.
What is the default embedded server in a Spring Boot servlet web application, and how does it get there?
basics
~10 sEmbedded Apache Tomcat. When you add spring-boot-starter-web, it transitively pulls in spring-boot-starter-tomcat, so Spring Boot auto-configures and starts an embedded Tomcat on port 8080 by default.
How do you enable HTTPS/TLS on Spring Boot's embedded web server?
basics
~10 sProvide a keystore file and set server.ssl.* properties: server.ssl.key-store (path), server.ssl.key-store-password, server.ssl.key-store-type, and server.ssl.key-alias. Spring Boot configures the embedded server's connector to serve HTTPS on server.port.
How do you change the port and base URL path of a Spring Boot app, and what are the defaults?
basics
~10 sSet server.port (default 8080) to change the listening port, and server.servlet.context-path (default /) to prefix every URL. Both go in application.properties/application.yml.
How do you switch a Spring Boot servlet app from Tomcat to Jetty or Undertow?
basics
~10 sExclude spring-boot-starter-tomcat from spring-boot-starter-web, then add spring-boot-starter-jetty (or spring-boot-starter-undertow). Boot's auto-configuration detects the new server on the classpath and uses it instead.
Explain `server.tomcat.threads.max` and `server.tomcat.accept-count`. How do they interact under load?
basics
~10 sthreads.max (default 200) is the max worker threads that process requests. accept-count (default 100) is the OS backlog queue of connections waiting when all threads are busy; beyond it, new connections are refused.
How do you build a container image from a Spring Boot application without writing a Dockerfile, and what mechanism makes this possible?
basics
~10 sRun the built-in goal: ./gradlew bootBuildImage (Gradle) or ./mvnw spring-boot:build-image (Maven). Spring Boot uses Cloud Native Buildpacks to turn your app into an OCI (Docker-compatible) container image, no Dockerfile needed.
How do you run a Spring Boot application locally with the Maven or Gradle plugin, and what do those plugins add over a plain build?
basics
~20 sWith Maven run mvn spring-boot:run; with Gradle run ./gradlew bootRun. Both compile and start your @SpringBootApplication main class in dev. The plugins also build an executable jar containing all dependencies so java -jar just works.
What is Spring Boot DevTools and what does it give you during development?
basics
~20 sspring-boot-devtools is an optional dev-only dependency. It automatically restarts your app when class files change, refreshes the browser via LiveReload, applies developer-friendly property defaults (like disabling template caching), and is left out of production jars.
What is a Spring Boot executable fat jar, and how is it structured internally?
basics
~10 sA single runnable jar containing your compiled classes plus all dependency jars. You run it with java -jar app.jar. Spring puts your code in BOOT-INF/classes and dependency jars in BOOT-INF/lib.
How do you control the resulting image's name and push it directly to a registry from bootBuildImage / spring-boot:build-image?
basics
~10 sSet the image name (imageName in Gradle, <image><name> in Maven, or --imageName= / -Dspring-boot.build-image.imageName=). To push, enable publish (publish = true / <publish>true</publish>) and provide registry credentials via docker.publishRegistry.