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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:35:26+00:00 2026-06-11T08:35:26+00:00

Spring configuration file creates beans and interconnects them. Is this correct? I have a

  • 0

Spring configuration file creates beans and interconnects them. Is this correct? I have a chain of beans in my application but want to test it with smaller chains. Can I have multiple chains defined with Spring? Or only one bean structure is allowed?

EXAMPLE

Suppose this is production config:

<bean id="provider"
    class="tests.Provider">
</bean>

<bean id="processor1" class="tests.Processor1">
    <property name="input" ref="provider"/>
</bean>

<bean id="processor2" class="tests.Processor2">
    <property name="input" ref="processor1"/>
</bean>

<bean id="consumer" class="tests.Consumer">
    <property name="input" ref="processor2"/>
</bean>

And I want to test in the following configs:

<bean id="provider"
    class="tests.Provider">
</bean>

<bean id="analyzer" class="tests.Analyzer">
    <property name="input" ref="provider"/>
</bean>

And:

<bean id="provider"
    class="tests.Provider">
</bean>

<bean id="processor1" class="tests.Processor1">
    <property name="input" ref="provider"/>
</bean>

<bean id="analyzer" class="tests.Analyzer">
    <property name="input" ref="processor1"/>
</bean>

And so on, attaching beans one by one.

  • 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-06-11T08:35:27+00:00Added an answer on June 11, 2026 at 8:35 am

    Yes, you can.

    You can break overall configuration of Spring application context for your application into parts (XML files if you use XML configuration, packages with @Components if you use classpath scanning, @Configurations if you use Java-based configuration) and construct an application context using a subset of these parts.

    So, if your application has two features foo and bar, you can declare beans used by these features in foo.xml and bar.xml respectively (if you use XML configuration), and import them from the main configuration of your application (such as applicationContext.xml).

    Now, if you want to write integration test for bar you can create application context from bar.xml only (@ContextConfiguration("bar.xml")). Obviously, you should take care of interdependencies between different parts of your configuration. For example, if both foo.xml and bar.xml depend on beans declared in db.xml, you may want to create something like test-db.xml and configure your integration test for bar as @ContextConfiguration({"bar.xml", "test-db.xml"}).

    Note that this approach requres some discipline, especially if you use classpath scanning – in this case parts of your configuration are defined by packages, therefore you need to follow “package by feature, not by layer” rule.

    See also:

    • 9.3 Integration testing
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GWT+Hibernate+JPA+Spring configuration file which is OK with Spring 3.0.x + Hibernate
I have a Spring JUnit test with configuration files and @ContextConfiguration parameters: package ru.csbi.registry.domain.envers.integration;
How does Spring Dispatcher Servlet create Default beans without any predefined XML configuration file.
I have created MVC application. I want to include js or css file into
I create an spring application with log4j in JBoss 7.1.1.FINAL this is my configuration
I'm trying to filter a Spring configuration file using Maven filtering. My POM is
To use Spring Integration in a Spring XML configuration file, I need to declare
I have been using the new feature of Spring 3.1.1 the java based configuration.
in common, hibernate sessionfactory is created in spring configuration file (eg spring-dao.xml) like; <bean
I'm writing web application that uses Spring MVC to bind Spring beans with REST-like

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.