nerdexam
Broadcom-VMware

2V0-72.22PSE · Question #1

Which two statements are correct when @SpringBootApplication is annotated on a class? (Choose two.)

The correct answer is A. It causes Spring Boot to enable auto-configuration by default. B. Component scanning will start from the package of the class. @SpringBootApplication is a composite annotation that bundles @EnableAutoConfiguration, @SpringBootConfiguration, and @ComponentScan - so A is correct because @EnableAutoConfiguration triggers Spring Boot's auto-configuration mechanism, and B is correct because @ComponentScan…

Core Spring

Question

Which two statements are correct when @SpringBootApplication is annotated on a class? (Choose two.)

Options

  • AIt causes Spring Boot to enable auto-configuration by default.
  • BComponent scanning will start from the package of the class.
  • CAll other annotations on the class will be ignored.
  • DMethods in the class annotated with @Bean will be ignored.
  • EA separate ApplicationContext will be created for each class annotated with

How the community answered

(21 responses)
  • A
    95% (20)
  • C
    5% (1)

Explanation

@SpringBootApplication is a composite annotation that bundles @EnableAutoConfiguration, @SpringBootConfiguration, and @ComponentScan - so A is correct because @EnableAutoConfiguration triggers Spring Boot's auto-configuration mechanism, and B is correct because @ComponentScan defaults to scanning the package of the annotated class and its sub-packages.

C is wrong - other annotations on the class are not ignored; they are processed normally alongside @SpringBootApplication. D is wrong - @SpringBootConfiguration (included in the composite) marks the class as a configuration class, so @Bean methods are actively picked up and registered. E is wrong - Spring Boot creates a single ApplicationContext for the application, not one per annotated class; having multiple classes with @SpringBootApplication would be unusual and problematic.

Memory tip: Think of @SpringBootApplication as a "triple combo" (@EnableAutoConfiguration + @ComponentScan + @SpringBootConfiguration) - the first gives you auto-config (A), the second gives you component scanning from the current package (B), and the third makes @Bean methods work, which rules out both C and D.

Topics

#@SpringBootApplication#auto-configuration#component-scanning#Spring Boot

Community Discussion

No community discussion yet for this question.

Full 2V0-72.22PSE Practice