Complete the code to mark the class as a configuration class.
@[1] public class AppConfig { }
The @Configuration annotation marks the class as a source of bean definitions for the Spring container.
Complete the code to define a bean method that returns a new instance of MyService.
@Bean public MyService [1]() { return new MyService(); }
The method name myService is used as the bean name by default.
Fix the error in the bean method declaration by completing the missing annotation.
@[1] public MyRepository [2]() { return new MyRepository(); }
The @Bean annotation is required on methods inside @Configuration classes to register beans. Also, the method needs a name.
Fill both blanks to complete the configuration class with a bean method.
@[1] public class ServiceConfig { @[2] public UserService userService() { return new UserService(); } }
The class must be annotated with @Configuration and the method with @Bean to define a bean.
Fill all three blanks to create a configuration class with two bean methods.
@[1] public class AppBeans { @[2] public ServiceA serviceA() { return new ServiceA(); } @[3] public ServiceB serviceB() { return new ServiceB(); } }
The class uses @Configuration, and each bean method uses @Bean to register beans.