S
S
sys_user2020-02-12 11:14:31
Java
sys_user, 2020-02-12 11:14:31

How to combine spring contexts into one?

Depending on how we create the beans, the context can be obtained via ClassPathXmlApplicationContext or AnnotationConfigApplicationContext.
But if the application uses two approaches (configuration of beans in xml and through annotations), then it turns out you need to work with two contexts. Is it possible to merge them or connect them one to another in order to get one context in which the beans were and those that are in xml and those that are configured with annotations?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Egor Lepikhin, 2020-02-12
@LepikhinEgor

There is an annotation @ImportResource("classpath:app-config.xml"), inside it, respectively, you write the path to xml with beans

A
Andrey Ryabov, 2020-02-12
@Vope

They have a common parent - GenericApplicationContext, it's more flexible, look this way
Documentation Link

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question