Bird
0
0

Identify the error in this Spring Boot main class:

medium📝 Debug Q14 of 15
Spring Boot - Fundamentals
Identify the error in this Spring Boot main class:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class App {
    public static void main(String[] args) {
        SpringApplication.run(App.class);
    }
}
AMissing second argument 'args' in SpringApplication.run call
BIncorrect annotation used instead of @SpringBootApplication
CMain method should return void, not be static
DClass name should be 'Application' not 'App'
Step-by-Step Solution
Solution:
  1. Step 1: Check SpringApplication.run parameters

    The method requires two arguments: the class and the args array from main method.
  2. Step 2: Identify missing argument

    The code calls SpringApplication.run(App.class) missing the second argument args, preventing command-line arguments from being passed to the application.
  3. Final Answer:

    Missing second argument 'args' in SpringApplication.run call -> Option A
  4. Quick Check:

    SpringApplication.run needs class and args [OK]
Quick Trick: SpringApplication.run needs both class and args [OK]
Common Mistakes:
  • Omitting args parameter in run method
  • Confusing annotation names
  • Changing main method signature incorrectly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes