Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
ClasspathXmlApplicationContext does not inherit/merge parent context environment [SPR-11068] #15695
I have a root ApplicationContext with environment as follows:
Then, when I create a new child context as follows:
its environment shows as follows:
So, no servlet stuff, no custom properties file in the propertySources.
However, creating the child context as follows behaves different:
Now, the childContext's environment shows as
From looking at the code, it becomes quite clear why this is: Using the given constructor of ClasspathXmlApplicationContext does not result in a call to AbstractApplicationContext.setParent(ApplicationContext parent) which would merge the environment of the parent into the own environment.
Juergen Hoeller commented
They all either delegate to AbstractApplicationContext's constructor with a parent argument or call setParent directly. Since this fix is actually in AbstractApplicationContext itself, we should have covered all implementations.
FYI, 3.2.5 should be available tomorrow morning :-)