Junior — Middle
Which class is used to interact with the Spring framework components?
sobes.tech AI
Answer from AI
Interaction with Spring components is done through the ApplicationContext class. This container manages the lifecycle of beans, their configuration, and dependencies. Through ApplicationContext, you can obtain the required bean by type or name.
Example of obtaining a bean from the context:
ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
MyService service = context.getBean(MyService.class);
service.doSomething();
There is also a more basic BeanFactory interface, but ApplicationContext extends its functionality and is used more often.