[{"id":"springbootbeginner-001","courseId":"spring-boot-beginner","domain":"configuration-and-beans","topic":"@SpringBootApplication annotation","prompt":"Your main class has only @SpringBootApplication and no other class-level annotations. Which three features does that one annotation switch on?","hint":"Think about what the shortcut annotation is made of, not what it is used for.","explain":"Spring Boot offers one annotation that switches on a bundle of core features for the main class. Knowing what the bundle contains tells you what you get for free.","source":"https://docs.spring.io/spring-boot/reference/using/using-the-springbootapplication-annotation.html","interaction":{"type":"single"},"options":[{"id":"a","text":"@EnableAutoConfiguration, @EnableWebMvc and @ComponentScan","whyNot":"@EnableWebMvc is not one of the three annotations the shortcut bundles."},{"id":"b","text":"@SpringBootConfiguration, @EnableAutoConfiguration and @ComponentScan","why":"The shortcut bundles exactly these three: extra bean configuration, auto-configuration and component scanning."},{"id":"c","text":"@Service, @Repository and @Controller","whyNot":"Those are stereotype annotations for individual classes; the shortcut does not bundle them."},{"id":"d","text":"@SpringBootConfiguration, @EnableJpaRepositories and @ComponentScan","whyNot":"@EnableJpaRepositories is not part of the bundle, which covers auto-configuration instead."}],"answer":"b","explanation":"@SpringBootApplication combines @SpringBootConfiguration, @EnableAutoConfiguration and @ComponentScan in one annotation.","concept":"@SpringBootApplication combines @SpringBootConfiguration, @EnableAutoConfiguration and @ComponentScan in one annotation.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["@SpringBootApplication is shorthand for three annotations; you can replace it with those three when you need finer control."]},{"id":"springbootbeginner-002","courseId":"spring-boot-beginner","domain":"configuration-and-beans","topic":"Main class in a root package","prompt":"Your project has com.example.shop.orders and com.example.shop.billing packages. Where should the @SpringBootApplication class go so that component scanning finds both?","hint":"Think about where the scan starts, and whether it reaches every sub-package of your project.","explain":"Component scanning starts at the main class's package and covers the packages below it. The place you put that class therefore decides which of your code gets picked up.","source":"https://docs.spring.io/spring-boot/reference/using/structuring-your-code.html","interaction":{"type":"single"},"options":[{"id":"a","text":"com.example.shop, the root package above the other packages","why":"A main class in a root package above the others lets component scanning cover every package below it."},{"id":"b","text":"com.example.shop.orders, next to the classes it works with","whyNot":"Scanning would start in orders and never reach the billing package."},{"id":"c","text":"The default package, with no package line at the top of the file","whyNot":"The default package is discouraged, and it makes Spring Boot read every class from every jar."},{"id":"d","text":"A new package, com.example.shop.app, kept apart from the rest","whyNot":"Scanning starts from the main class's package, so this one would miss orders and billing."}],"answer":"a","explanation":"The main class's package is the base search package: a root package above the others makes scanning cover all of them.","concept":"The main class's package is the base search package: a root package above the others makes scanning cover all of them.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Keep the main class in a root package so component scanning covers every feature package below it."]},{"id":"springbootbeginner-003","courseId":"spring-boot-beginner","domain":"configuration-and-beans","topic":"Starter dependencies","prompt":"A new Spring Boot project is built with Maven or Gradle. Which TWO statements about dependencies and starters are correct?","hint":"Think about what you must type in the build file, and what a starter is meant to save you from.","explain":"A build file names the libraries a project needs, and each library has a version. Frameworks can publish a curated set of versions and grouped dependency sets to make that less work.","source":"https://docs.spring.io/spring-boot/reference/using/build-systems.html","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"A starter is a runnable JAR that Spring Boot launches at startup.","whyNot":"Starters are dependency descriptors that pull in libraries; they do not run anything on their own."},{"id":"b","text":"You can leave the version off most Spring dependencies, because Spring Boot's curated list manages them.","why":"Each Spring Boot release ships a curated list of dependency versions, so your build file does not need to declare them."},{"id":"c","text":"You must pin every dependency to an exact version yourself, even with Spring Boot's dependency management.","whyNot":"Spring Boot manages the versions of the curated dependencies, so pinning each one is not required."},{"id":"d","text":"Adding spring-boot-starter-data-jpa brings in the dependencies for Spring and JPA database access in one include.","why":"A starter bundles the libraries needed for a common purpose, so one entry replaces a long list."},{"id":"e","text":"You must set the Spring Framework version yourself, because Spring Boot does not choose one.","whyNot":"Each Spring Boot release is tied to a base Spring Framework version, and the docs advise against specifying it."},{"id":"f","text":"Starters work only with Maven, so Gradle projects must list each library by hand.","whyNot":"The docs recommend Maven or Gradle, and starters are dependency descriptors that either build tool can use."}],"answer":"bd","explanation":"Spring Boot curates dependency versions so most need no version, and starters bundle the dependencies for a common need.","concept":"Spring Boot curates dependency versions so most need no version, and starters bundle the dependencies for a common need.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Leave versions to Spring Boot's dependency management and add a starter for each major feature you need."]},{"id":"springbootbeginner-004","courseId":"spring-boot-beginner","domain":"configuration-and-beans","topic":"Constructor injection","prompt":"A service needs a RiskAssessor. The team wants the field to be final, so it cannot be reassigned after the object is built. Which wiring style gives them that?","hint":"Think about where the dependency gets stored, and when it is handed to the object.","explain":"A bean can receive the objects it depends on in several ways. The way they arrive decides whether the object is complete as soon as it is created and whether its fields can be final.","source":"https://docs.spring.io/spring-boot/reference/using/spring-beans-and-dependency-injection.html","interaction":{"type":"single"},"options":[{"id":"a","text":"Field injection: @Autowired on a private RiskAssessor field.","whyNot":"The field is assigned after construction rather than in a constructor, so it cannot be marked final in the usual way."},{"id":"b","text":"Setter injection: a public setRiskAssessor method that Spring calls after construction.","whyNot":"A setter changes the field later, which is the opposite of final."},{"id":"c","text":"Constructor injection: Spring passes the RiskAssessor into the constructor, which stores it in a final field.","why":"Constructor injection sets the field once, inside the constructor, so it can be declared final."},{"id":"d","text":"Creating the object inside the service with new RiskAssessor().","whyNot":"Building the dependency yourself is not injection, so the container cannot supply or swap it."}],"answer":"c","explanation":"Constructor injection passes dependencies in through the constructor, so the field can be final and the object is complete when built.","concept":"Constructor injection passes dependencies in through the constructor, so the field can be final and the object is complete when built.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Prefer constructor injection, which lets a dependency field be declared final."]},{"id":"springbootbeginner-005","courseId":"spring-boot-beginner","domain":"configuration-and-beans","topic":"@Bean methods in @Configuration classes","prompt":"Because this class is annotated only with @Component, first() and second() return the same Store object.","hint":"Think about whether a normal Java method call passes through the container.","explain":"A @Bean method is normally called by the container, which hands out one shared object. Whether a plain Java call gets the same treatment depends on the class annotation.","source":"https://docs.spring.io/spring-framework/reference/core/beans/java/basic-concepts.html","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"Without @Configuration, a call to store() is a plain Java call, so each call runs the method and creates a new Store."},{"id":"b","text":"False","why":"The container does not intercept those calls in this class, so first() and second() each get a new object."}],"answer":"b","explanation":"In lite mode (no @Configuration, or proxyBeanMethods=false), a direct Java call to a @Bean method is not intercepted and creates a new instance each time.","concept":"In lite mode (no @Configuration, or proxyBeanMethods=false), a direct Java call to a @Bean method is not intercepted and creates a new instance each time.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","code":"@Component\nclass Wiring {\n    @Bean\n    Store store() {\n        return new Store();\n    }\n\n    Store first() { return store(); }\n    Store second() { return store(); }\n}","takeaways":["Plain Java calls to @Bean methods bypass the container in lite mode, so each call creates a new object."]}]