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

  • SEARCH
  • Home
  • 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 187529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:50:23+00:00 2026-05-11T15:50:23+00:00

I have a multi-module (maven) spring build. All the modules publish some beans, and

  • 0

I have a multi-module (maven) spring build. All the modules publish some beans, and most also consume beans defined further down the dependency graph. Although most of it is annotation declared beans, almost every module also has one or two xml-declared beans.

Although we have a half-decent solution, but I am really wondering what is the correct/optimal way to organize the xml files in this scenario? Do you use import between the modules or is there some other way ? Do you put all the xml files in one place or spread them around according to the dependency graph? How does your solution handle partial spring contexts (typical integration tests) ?

I’d also like to have this organized in a way that lets me leverage my IDE’s spring support optimally (IDEA and a few eclipse users).

  • 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. 2026-05-11T15:50:24+00:00Added an answer on May 11, 2026 at 3:50 pm

    We use wildcarded imports in the modules to allow other modules contribute beans to the module declaring the import:

    <import resource='classpath*:com/acme/**/*-core-support.xml' /> 

    Modularity

    Modules that want to contribute to the ‘host’ just have to place a correctly named files in src/main/resources/com/acme in this case to be picked up automagically. If you use classpath scanning (by <context:component-scan /> it will become even easier).

    Another thing that helps in that regard is some small Spring extension that picks up beans of a given type and republishes them in ApplicationContext again. By doing something like this:

    <plugin:list id='beanList' class='com.acme.MyCoolPluginInterface' />  <bean class='com.acme.MyPluginHost'>    <property name='plugins' ref='beanList' /> </bean> 

    In combination with the wildcarded import this will:

    1. Collect all beans found in the ApplicationContext that implement MyCoolPluginInterface and wrap them in a list registered as beanList in the ApplicationContext.
    2. Allow the MyPluginHost to reference that list.

    In fact, you now can simply extend your app by adding plugin modules to the classpath (aka dependency in Maven).

    That tiny Spring extension is called Spring Plugin and published under Apache 2 licence. See http://github.com/SpringSource/spring-plugin for more info. There’s also a more advanced sample project at Github, that shows how this works and improves modularity at GitHub. The app is sample code for my ‘Whoops! Where did my architecture go?’ presentation which you can see the slides here or watch a recording here.

    Different environments

    Usually we configure our apps to run in the target environment (using JNDI lookups and stuff). Of course you would like to use the standard PropertyPlaceholderConfigurer mechanisms to externalize configuration that has to be touched by admins or will change through various environments.

    For integration tests we usually have additional config files in src/main/test that get loaded additionally to the normal config files overriding the critical beans that tie the configuration to the environment. E.g. if you have a datasource in your normal config file

     <jee:jndi-lookup id='dataSource' jndi-name='jdbc/MyDataSource' /> 

    you would override this in your test-context.xml by using

     <bean id='dataSource' class='...DataSource' />     <!-- config -->  </bean> 

    and importing that after the original one in the test class

     @ConfigurationContext(locations = {'app-context.xml', 'test-context.xml'})  public FooBarIntegrationtest {    // ...  } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 104k
  • Answers 104k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Python 2.x: print '-' * 3 Python 3.x: print('-' *… May 11, 2026 at 8:31 pm
  • Editorial Team
    Editorial Team added an answer Implement the callback as a private class function, passing '$this->callback_function'… May 11, 2026 at 8:31 pm
  • Editorial Team
    Editorial Team added an answer When you have only, say, 2 buttons left, since you… May 11, 2026 at 8:31 pm

Related Questions

I have a multi-module maven project with an installer sub-project. The installer will be
I have a large application (~50 modules) using a structure similar to the following:
I'm developing a DirectShow application. I encounter a deadlock problem, the problem seems caused
How can I define a multi-statement function or procedure in using the MySQLdb lib
New to Linux programming in general. I am trying to communicate with a kernel

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.