Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7459087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T14:02:04+00:00 2026-05-29T14:02:04+00:00

Here’s the scenario: I have a standard applicationConfig.xml spring configuration for a basic web

  • 0

Here’s the scenario:

I have a standard applicationConfig.xml spring configuration for a basic web app. It works great. I also have a “core jar” for one of our internal dependencies for a different app. The “core jar” has an AnnotationConfigApplicationContext which registers the different @Configuration beans appropriately. I’m trying to use the annotation @Configuration beans in the app which is configured using the applicationConfig.xml.

I can dream up two options which I believe will work:

  1. Refactor the xml config to also use the annotationConfig and register the different configurations to the context the same way our “core jars” do.

  2. Create a second context and access it directly instead of having the singletons/prototypes live on the same applicationContext as the xml config. I’d really rather not do this as it seems more like a hack than an elegant solution (and I’m not entirely sure it would behave as I’d want it to.)

  3. What I’m dreaming of, but can’t find any documentation to support

I’d like to register the annotation configuration bean into the application context somehow, but I can’t get the objects to line up the way I’d like them to (aka, my context won’t .register() the @Configuration file – only 1 bean at a time….)

Just to follow up – I got this working (YAY). In my case, I ended up following the general pattern set forth by gpeche.

The applicationContext-parent.xml contained the 1 bean def:

<bean id="parentApplicationContext" class="org.springframework.context.annotation.AnnotationConfigApplicationContext" scope="singleton">
    <constructor-arg>
      <list>
        <value>com.package.CoreCommonInContainerConfigImpl</value>
        <value>com.package.CoreCommonCommonConfigImpl</value>
      </list>
    </constructor-arg>
</bean>

where the CoreCommon****Impl classes are @Configuration annotated classes which define beans for that context.

As gpeche noted, an @Autowired Bean bean; inside of a controller (for example) falls back on the parent context and resolves automagically.

THANKS!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T14:02:20+00:00Added an answer on May 29, 2026 at 2:02 pm

    What I would do:

    1) In my WAR, put an additional Spring context file, say applicationContext-parent.xml.

    <beans ...>
        <bean id="parentApplicationContext" class="org.springframework.context.annotation.AnnotationConfigApplicationContext" scope="singleton">
        <!-- Any other configuration for your annotation-configured context -->
    </beans>
    

    2) Specify this in my web.xml:

    <!-- Where do I have my parent context? -->
    <context-param>
        <param-name>locatorFactorySelector</param-name>
        <param-value>path/to/applicationContext-parent.xml</param-value>
    </context-param>
    
    <!-- How is my parent context called? -->
    <context-param>
        <param-name>parentContextKey</param-name>
        <param-value>parentApplicationContext</param-value>
    </context-param>
    

    With this configuration, you will have parent/child contexts and not a “real” merged context, but you should be able to inject beans from the parent context into child context beans in the usual way, the child context will fall back to the parent context when trying to resolve beans.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my scenario - I have an SSIS job that depends on another prior
Here is the scenario: I'm writing an app that will watch for any changes
Here is what I have: Dim cmsManager As New Telerik.Cms.CmsManager() Dim currentNode As Telerik.Cms.Web.CmsSiteMapNode
Here's the basic setup: I have a thin bar at the top of a
Here's the scenario: I have a local git repository that mirrors the contents of
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here we go again, the old argument still arises... Would we better have a
Here's my scenario. I've got SharePoint 2010 running on one server, with an SQL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.