How to import spring application context into another application context?

I have two spring application contexts. One of them is local to my application, and the other is from one of the maven dependencies.

Now my applicationContext.xml file looks like this.

<import resource="classpath*:**/sample-applicationContext.xml" />

and I'm <context:component-scan>in a file sample-applicationContext.xmlthat scans components.

and now when i do the following.

ApplicationContext ctx=new ClassPathXmlApplicationContext("applicationContext.xml");
MyClass m=ctx.getBean(MyClass.class);

Unfortunately, when I get the object MyClass, the object is created, however, I see that no dependencies MyClassare entered.

The MyClassstartup-dependent beans are scanned using the <context:component-scan>in file sample-applicationContext.xml.

, Maven autwire beans ?

+4
2

, spring applicationContext.

ApplicationContext context = 
new ClassPathXmlApplicationContext(new String[] {"sample-applicationContext.xml",   "applicationContext.xml"});

, Context.xml, sample-applicationContext.xml MyClass.

0

All Articles