[{"id":"springbootadvanced-001","courseId":"spring-boot-advanced","domain":"configuration-and-beans","topic":"Lookup method injection","prompt":"You want the container to override createCommand() on a CommandManager so each call returns a fresh prototype Command. You create the CommandManager with a @Bean method in a @Configuration class. Will the override happen?","hint":"Consider who builds the instance, and what the container must generate to override a method.","explain":"Lookup method injection has the container override a method to return a named bean on each call. It uses a generated subclass, so the class, the method and the way the instance is made all matter.","source":"https://docs.spring.io/spring-framework/reference/core/beans/dependencies/factory-method-injection.html","interaction":{"type":"single"},"options":[{"id":"a","text":"No override happens: lookup methods don't work with @Bean factory methods.","why":"The container isn't in charge of creating a @Bean instance, so it can't generate the subclass that performs the override."},{"id":"b","text":"It works, because the Command bean is a prototype and lookup needs one.","whyNot":"A prototype target is typical for lookup, but it doesn't make a factory-method instance overridable."},{"id":"c","text":"It works, because CGLIB overrides every method of any singleton bean.","whyNot":"Only non-final methods of container-created instances can be overridden; @Bean factory methods are excluded."},{"id":"d","text":"It works only if createCommand() is declared abstract.","whyNot":"Abstract is one allowed form, but concrete methods are overridden too; the @Bean factory is the real blocker."}],"answer":"a","explanation":"Lookup method injection relies on a generated CGLIB subclass, which the container can build only for instances it creates itself, not for @Bean factory methods.","concept":"Lookup method injection relies on a generated CGLIB subclass, which the container can build only for instances it creates itself, not for @Bean factory methods.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Lookup methods don't work with @Bean factory methods, since the container must create the instance to subclass it."]},{"id":"springbootadvanced-002","courseId":"spring-boot-advanced","domain":"configuration-and-beans","topic":"proxyBeanMethods=false on @Configuration","prompt":"Your config class uses @Configuration(proxyBeanMethods = false). True or false: its @Bean methods should get their collaborators through constructor or method parameters rather than by calling each other.","hint":"Consider what the CGLIB subclass normally does when one @Bean method calls another.","explain":"A @Configuration class is subclassed with CGLIB by default, so a call from one @Bean method to another returns the cached bean. The proxyBeanMethods attribute controls whether such calls are intercepted.","source":"https://docs.spring.io/spring-framework/reference/core/beans/java/configuration-annotation.html","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","why":"Cross-method calls between @Bean methods are not intercepted here, so the beans must be wired through dependency injection."},{"id":"b","text":"False","whyNot":"With proxyBeanMethods = false, those calls are not intercepted, so a direct call doesn't return the cached singleton."}],"answer":"a","explanation":"With proxyBeanMethods = false, calls between @Bean methods are not intercepted, so dependencies must come from constructor or method injection.","concept":"With proxyBeanMethods = false, calls between @Bean methods are not intercepted, so dependencies must come from constructor or method injection.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["With proxyBeanMethods = false, inject @Bean collaborators as parameters instead of calling their methods."]},{"id":"springbootadvanced-003","courseId":"spring-boot-advanced","domain":"configuration-and-beans","topic":"BeanPostProcessor callbacks","prompt":"A bean has an init method, and a custom BeanPostProcessor is registered in the context. Put these steps of one bean's container lifecycle in the order the container runs them.","hint":"A post-processor needs an instance to work on, so think about what must exist first.","explain":"A BeanPostProcessor is a hook that receives bean objects; it does not make them. Work out what a hook can only act on once that object exists, and which steps belong to the container's own lifecycle.","source":"https://docs.spring.io/spring-framework/reference/core/beans/factory-extension.html","interaction":{"type":"sort","items":[{"text":"The container instantiates the bean instance","why":"A BeanPostProcessor works on bean instances, so the instance must exist first."},{"text":"Post-processor callback before initialization","why":"It runs before any container initialization methods are called."},{"text":"Initialization methods, such as afterPropertiesSet() or a declared init method","why":"They run after the before-initialization callback and before the after-initialization callbacks."},{"text":"Post-processor callback after initialization","why":"It runs after any bean initialization callbacks have finished."}]},"options":[],"answer":"o:abcd","explanation":"The container instantiates a bean, then BeanPostProcessors get a callback before initialization methods run and another after the bean initialization callbacks.","concept":"The container instantiates a bean, then BeanPostProcessors get a callback before initialization methods run and another after the bean initialization callbacks.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["A BeanPostProcessor sees each bean instance before and after its initialization methods run."]},{"id":"springbootadvanced-004","courseId":"spring-boot-advanced","domain":"configuration-and-beans","topic":"@DependsOn creation and destruction order","prompt":"A bean declares depends-on='migrations'. Which TWO statements about depends-on are correct?","hint":"The attribute affects more than the moment the bean is created.","explain":"depends-on is an explicit ordering hint between beans that have no direct reference to each other. It affects when beans start and, for some beans, when they shut down.","source":"https://docs.spring.io/spring-framework/reference/core/beans/dependencies/factory-dependson.html","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"The named bean is initialized before the bean that declares depends-on.","why":"depends-on forces the listed beans to be initialized before the bean that uses it."},{"id":"b","text":"For singleton beans, dependent beans are destroyed before the bean they depend on.","why":"depends-on also sets a destruction-time order for singletons, so dependents are destroyed first."},{"id":"c","text":"The named bean is injected into the dependent bean as a property.","whyNot":"depends-on only orders initialization; it sets no property. Injection needs a ref or autowiring."},{"id":"d","text":"The named bean is destroyed before the bean that declares depends-on.","whyNot":"The reverse holds: dependent beans are destroyed first, so the declaring bean goes before the named one."},{"id":"e","text":"depends-on applies only to prototype-scoped beans.","whyNot":"It sets initialization order generally; only the destruction-time order is limited to singletons."},{"id":"f","text":"A depends-on value can list only one bean name at a time.","whyNot":"The attribute accepts a list of names separated by commas, whitespace or semicolons."}],"answer":"ab","explanation":"depends-on forces named beans to initialize first; for singletons it also makes dependents destroyed before the beans they rely on.","concept":"depends-on forces named beans to initialize first; for singletons it also makes dependents destroyed before the beans they rely on.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["depends-on orders startup without injecting anything; for singletons it also orders shutdown."]},{"id":"springbootadvanced-005","courseId":"spring-boot-advanced","domain":"configuration-and-beans","topic":"System properties versus environment variables precedence","prompt":"True or false: the Spring Environment draws property values only from properties files, so JVM system properties and OS environment variables are not consulted.","hint":"List the places an application's property values can come from.","explain":"The Environment models profiles and properties, and property values can originate from many kinds of sources. Know what those sources are before judging which ones the container reads.","source":"https://docs.spring.io/spring-framework/reference/core/beans/environment.html","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"The Environment also resolves properties from JVM system properties and system environment variables, not just files."},{"id":"b","text":"False","why":"JVM system properties and system environment variables are both property sources the Environment resolves from."}],"answer":"b","explanation":"The Environment resolves properties from several sources, including properties files, JVM system properties and system environment variables.","concept":"The Environment resolves properties from several sources, including properties files, JVM system properties and system environment variables.","rev":1,"updatedAt":"2026-10-23","kind":"scenario","takeaways":["Spring's Environment reads properties from many sources, not only application files."]}]