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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:10:48+00:00 2026-06-17T20:10:48+00:00

I am studying Spring MVC. Today, trying to understand how implement a JDBC DAO,

  • 0

I am studying Spring MVC. Today, trying to understand how implement a JDBC DAO, I have found this "Hello World" in Spring (Spring, not Spring MVC) and I begin to see it (because I think that to realize a DAO I have to create a separate Spring Project that execute the access to the data…)

http://www.tutorialspoint.com/spring/spring_hello_world_example.htm

OK, this is a standalone application and this is not a web application, so it doesn’t have the web application structure (WEB-INF folder, web.xml file and the dispatcher servlet configuration file that I have in my web app)

In this example I have a Beans.xml configuration file that is used to assign unique IDs to different beans and to control the creation of objects with different values without impacting any of the Spring source files…

For example in this example I use the Beans.xml file to pass the "Hello World" message value for "message" variable and so I can print this value without impacting HelloWorld.java and MainApp.java files

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

   <bean id="helloWorld" class="com.tutorialspoint.HelloWorld">
       <property name="message" value="Hello World!"/>
   </bean>

</beans>

So I have some question for you about it:

  1. Is this file the file that configure my Bean Factory? I think that, as well as I pass a text value as the value of a variable I could also inject a bean as a dependency of another bean.

    Is it right?

  2. In this example, can I don’t use the Beans.xml file and using in place of the annotation system?

  • 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-17T20:10:49+00:00Added an answer on June 17, 2026 at 8:10 pm

    1) This Beans.xml (actually you can name it whatever you want) is a Spring configuration file. It holds a configuration metadata.

    From the official Spring documentation:

    5.2.1 Configuration metadata

    As the preceding diagram shows, the Spring IoC container consumes a
    form of configuration metadata; this configuration metadata represents
    how you as an application developer tell the Spring container to
    instantiate, configure, and assemble the objects in your application.

    Configuration metadata is traditionally supplied in a simple and intuitive XML format, but it is not the only allowed form of configuration metadata (see the answer to your second question)

    And yes, you are right: you can inject another bean as a reference.

    From the official Spring documentation:

    5.3 Bean overview

    A Spring IoC container manages one or more beans. These beans are
    created with the configuration metadata that you supply to the
    container, for example, in the form of XML definitions.

    Within the container itself, these bean definitions are represented as
    BeanDefinition objects, which contain (among other information) the
    following metadata:

    • A package-qualified class name: typically the actual implementation class of the bean being defined.

    • Bean behavioral configuration elements, which state how the bean should behave in the container (scope, lifecycle callbacks, and so
      forth).

    • References to other beans that are needed for the bean to do its work; these references are also called collaborators or
      dependencies
      .

    • Other configuration settings to set in the newly created object, for example, the number of connections to use in a bean that manages a
      connection pool, or the size limit of the pool.

    Simple example of using references to other beans from the official documentation:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans.xsd">
    
        <bean id="exampleBean" class="examples.ExampleBean">
            <!-- setter injection using the nested <ref/> element -->
            <property name="beanOne">
                <ref bean="anotherExampleBean"/>
            </property>
    
            <!-- setter injection using the neater 'ref' attribute -->
            <property name="beanTwo" ref="yetAnotherBean"/>
            <property name="integerProperty" value="1"/>
        </bean>
    
        <bean id="anotherExampleBean" class="examples.AnotherBean"/>
        <bean id="yetAnotherBean" class="examples.YetAnotherBean"/>
    
    </beans>
    

    2)
    From the official Spring documentation:

    5.2.1 Configuration metadata

    …

    XML-based metadata is not the only allowed form of configuration
    metadata
    . The Spring IoC container itself is totally decoupled from
    the format in which this configuration metadata is actually written.

    For information about using other forms of metadata with the Spring
    container, see:

    • Annotation-based configuration:
      Spring 2.5 introduced support for annotation-based configuration
      metadata.

    • Java-based configuration:
      Starting with Spring 3.0, many features provided by the Spring
      JavaConfig project became part of the core Spring Framework. Thus you
      can define beans external to your application classes by using Java
      rather than XML files. To use these new features, see the
      @Configuration, @Bean, @Import and @DependsOn annotations.

    Also read this:
    Spring Without XML: The Basics of Spring Annotations vs. Spring XML Files

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

Sidebar

Related Questions

I am studyng Spring MVC and I have find this simple Hello World tutorial:
I am quite new in the Spring MVC World. Today I am studing the
I have started to learn ASP.NET MVC, and at this time of studying I
in this period I am studying the Spring MVC showcase example dowlodable from STS
in this period I am studying the Spring MVC showcase example. Now I am
I was just studying OCPJP questions and I found this strange code: public static
I'm studying apply and I am trying to understand why the code I am
In this period I am studying the Sping MVC showcase example dowlodable form STS
I'm studying for a Discrete Mathematics test and I found this exercise which I
I am pretty new in Spring MVC. Currently I am studying the Spring MVC

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.