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 7004687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:13:51+00:00 2026-05-27T21:13:51+00:00

My main Spring Configuration XML file specifies something like this: <context:component-scan base-package=com.application /> The

  • 0

My main Spring Configuration XML file specifies something like this:

<context:component-scan base-package="com.application" />

The components found during this scan can be in one of many jar files on my classpath. I’d like to be able to have additional spring configuration XML files in each jar file that provide more information about each individual service/component (maybe some properties and whatnot), but I don’t want these things to be tightly coupled to my main application’s configuration file.

Is there a way to do this, or am I out of luck?

Ideally, I’d like to be able to somehow autodetect the existence of the XML file in the JAR file, based on name and/or location in the JAR file.

I know some things like this can be done with META-INF, but that’s far beyond my area of expertise.

  • 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-27T21:13:52+00:00Added an answer on May 27, 2026 at 9:13 pm

    Ideally, I’d like to be able to somehow autodetect the existence of the XML file in the JAR file, based on name and/or location in the JAR file.

    Yes, this is pretty straightforward.

    In your main Spring context file, add something like this:

    <import resource="classpath*:config.xml"/>
    

    Note the wildcard syntax. This will scan the root of the classpath looking for any resources called config.xml, and will import them into your main context.

    So your JARs can each have a config.xml in their root directory, and it’ll just happen. Those config.xml files can, of course, perform their own imports, and so on.

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

Sidebar

Related Questions

I'm trying to instantiate XMLConfiguration from spring appcontext, my configuration file is in src/main/resources/
Problem Given the following XML configuration file: <main> <name>JET</name> <maxInstances>5</maxInstances> <parameters> <a>1</a> <b> <b1>test1</b1>
I have this web application using Spring Web Flow framework. In my main page
my main.xml file is just dummy. I want to start different activites based on
I am using an XML configuration file that is loaded into my Java application
I have a maven based Spring 3.0 project. The Spring configuration file for the
My application uses a Spring DefaultMessageListenerContainer to process incoming messages. The main method of
I am using Struts2, Spring 2 and Junit 4.5. My main question is, whether
static void Main(string[] args) { //read in the file StreamReader convert = new StreamReader(../../convert.txt);
I am using a class library which represents some of its configuration in .xml.

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.