Bird
0
0

Given this Spring Boot application snippet, what will happen if spring-boot-starter-web is on the classpath?

medium📝 component behavior Q13 of 15
Spring Boot - Fundamentals
Given this Spring Boot application snippet, what will happen if spring-boot-starter-web is on the classpath?
@SpringBootApplication
public class DemoApplication {
  public static void main(String[] args) {
    SpringApplication.run(DemoApplication.class, args);
  }
}
ASpring Boot auto-configures a web server and MVC setup
BNo web server is configured automatically
CApplication fails to start due to missing annotations
DOnly a command-line runner is configured
Step-by-Step Solution
Solution:
  1. Step 1: Check classpath dependency effect

    Presence of spring-boot-starter-web triggers auto-configuration of embedded web server and MVC components.
  2. Step 2: Analyze application code

    The main class is annotated with @SpringBootApplication, enabling auto-configuration which activates for web components due to the starter-web dependency.
  3. Final Answer:

    Spring Boot auto-configures a web server and MVC setup -> Option A
  4. Quick Check:

    Web starter on classpath = web auto-config [OK]
Quick Trick: Web starter triggers web server auto-config [OK]
Common Mistakes:
  • Ignoring the effect of dependencies on auto-config
  • Assuming no server without explicit config
  • Forgetting @SpringBootApplication annotation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes