ApplicationRunner vs CommandLineRunner, the Spring Boot CLI, dependency management and version conflicts, changing or disabling the embedded server, excluding auto-configurations, non-web apps, and how an HTTPS request flows through a Boot app.
Published September 25, 2026
These questions check that you've actually run Spring Boot applications: changed ports, fixed dependency conflicts, run start-up tasks. Give the exact property names. That's what makes the answers credible.
ApplicationRunner?Short answer: A callback interface. Any ApplicationRunner bean's run(ApplicationArguments args) method executes once, after the application context has started, and just before the app is reported as ready. It's used for start-up tasks: seeding reference data, warming caches, validating configuration.
@Component
class CacheWarmer implements ApplicationRunner {
private final ProductCatalog catalog;
CacheWarmer(ProductCatalog catalog) { this.catalog = catalog; }
@Override public void run(ApplicationArguments args) {
if (args.containsOption("skip-warmup")) return; // --skip-warmup
catalog.loadTopSellers();
}
}
CommandLineRunner, and how does it differ from ApplicationRunner?Short answer: It serves the same purpose. The difference is the arguments: CommandLineRunner.run(String... args) receives the raw argument strings, while ApplicationRunner receives parsed ApplicationArguments, where you can query options (--name=value) separately from non-option arguments.
Key points to cover:
@Order, or by implementing Ordered.ApplicationReadyEvent instead.Short answer: A command-line tool for bootstrapping Spring Boot projects:
spring init: generate a project from Spring Initializr, for example spring init --dependencies=web,data-jpa demo.spring help.spring encodepassword: create a hashed password for Spring Security.Key points to cover:
spring run app.groovy and spring test for running Groovy scripts. That script-running support was removed in Spring Boot 3. Today the CLI is mainly a project generator, and most developers use start.spring.io or their IDE instead.Short answer: Spring Boot publishes a bill of materials (spring-boot-dependencies) that pins compatible versions of hundreds of libraries: Hibernate, Jackson, Tomcat, Kafka clients and more. When you inherit spring-boot-starter-parent, or import the BOM, you declare dependencies without versions, and they're guaranteed to work together.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.1</version>
</parent>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <!-- no version: managed -->
</dependency>
Key points to cover:
<jackson-bom.version>, rather than hard-coding a version on one artifact.Short answer: Maven and Gradle each put only one version of an artifact on the classpath:
If the chosen version is incompatible with some library, you get runtime errors such as NoSuchMethodError or ClassNotFoundException.
Key points to cover:
mvn dependency:tree -Dverbose or gradle dependencyInsight --dependency jackson-databind.<exclusions>, or pinning a version in <dependencyManagement>.Common trap: saying the build tool "picks the most compatible version". It doesn't check compatibility at all. It applies mechanical rules.
Short answer: Set server.port:
server:
port: 9090 # application.yml
Or override it at launch: java -jar app.jar --server.port=9090, or with the environment variable SERVER_PORT=9090.
Key points to cover:
server.port=0 picks a random free port. That's useful in tests, together with @LocalServerPort.WebServerFactoryCustomizer<ConfigurableServletWebServerFactory>.Short answer: 8080, for Tomcat, and also for Jetty, Undertow, and Netty in WebFlux. The management (Actuator) endpoints use the same port unless you set management.server.port.
Short answer: Yes. Set spring.main.web-application-type=none, and Spring Boot starts a plain application context with no web server. That's useful for batch jobs, Kafka consumers or CLI tools. You can also leave the web starter out entirely.
new SpringApplicationBuilder(BatchApp.class).web(WebApplicationType.NONE).run(args);
Short answer: Use the exclude attribute, or a property:
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class App { }
spring:
autoconfigure:
exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
Key points to cover:
Short answer: Absolutely. Batch jobs, schedulers, message consumers and command-line tools all benefit from Boot's DI, configuration and auto-configuration without needing a web server. Leave out the web starter, or set web-application-type=none, and put your logic in a CommandLineRunner, @Scheduled methods or @KafkaListeners.
Short answer:
DispatcherServlet asks the HandlerMapping for the matching controller method.@PathVariable, @RequestParam, and @RequestBody JSON deserialised by Jackson, plus @Valid validation.@Transactional), which calls a repository (database).HttpMessageConverter, and exceptions go through @ControllerAdvice handlers.Key points to cover:
server.ssl.* properties, or SSL bundles (spring.ssl.bundle.*, Boot 3.1+).server.forward-headers-strategy=framework, so that redirects and generated links still use https.Learn it in depth → REST Controllers
Q: What is the order of precedence for configuration sources? A: From highest to lowest (simplified):
application-prod.yml).application.yml.Later sources override earlier ones for the same key.
Q: How do you switch from Tomcat to Jetty or Undertow?
A: Exclude spring-boot-starter-tomcat from spring-boot-starter-web, and add spring-boot-starter-jetty (or -undertow). Auto-configuration detects the server on the classpath.
Q: What is graceful shutdown?
A: With server.shutdown=graceful, the server stops accepting new requests on SIGTERM, and lets in-flight requests finish within spring.lifecycle.timeout-per-shutdown-phase. That matters for zero-downtime deployments on Kubernetes.
Q: application.properties or application.yml?
A: They're functionally equivalent. YAML is more readable for nested and list configuration, and supports multi-document files. Pick one per project, and stay consistent.