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

The Archive Base Latest Questions

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

I am studyng Spring MVC and I have find this simple Hello World tutorial:

  • 0

I am studyng Spring MVC and I have find this simple Hello World tutorial: http://www.tutorialspoint.com/spring/spring_hello_world_example.htm

In this tutorial the author creat a Bean Configuration file named Beans.xml, something like this:

<?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>

Using tis file the Spring Framework can create all the beans defined and assign them a unique ID as defined in tag. And I can use tag to pass the values of different variables used at the time of object creation.

Is this the well know Bean Factory?

My doubt is related to the following thing: in my previous example I don’t use a Bean Configuration file to define my bean, but I use the annotation to define what is a Spring bean and how this bean work (for example I use @Controller annotation to say Spring that a class act as a Controller Bean)

Use the bean configuration file and use the annotation have the same meaning?

Can I use both?

For example, if I have to configure JDBC can I configure it inside beans.xml file and at the same time can I use annotaions for my Controller class?

Tnx

  • 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-17T11:48:08+00:00Added an answer on June 17, 2026 at 11:48 am

    Yes you can do that thing. Find a example below where controller has written with annotation and sessionFactory and data source has been created as xml bean which is wired into services –

    <beans ...>
        <!-- Controller & service base package -->
        <context:component-scan base-package="com.test.employeemanagement.web" />
        <context:component-scan base-package="com.test.employeemanagement.service"/>
    
        <bean id="dataSource"
            class="org.springframework.jdbc.datasource.DriverManagerDataSource">
               ...
        </bean>
        <bean id="sessionFactory"
            class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="annotatedClasses">
            <list>
                <!-- <value>com.vaannila.domain.User</value> -->
                <value>com.test.employeemanagement.model.Employee</value>
                ...
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${hibernate.dialect}</prop>
                ...
            </props>
        </property>
        </bean>
        ...
    </beans>
    

    Services Example where SessionFactory is injected.

    @Repository
    public class EmployeeDaoImpl implements EmployeeDao {
    
        @Autowired
        private SessionFactory sessionFactory;
    }
    

    I hope it helps you. 🙂

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

Sidebar

Related Questions

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 studing the Spring MVC showcase example (downloadable from STS
In this period I am studing the Spring MVC Showcase example dowlodable from the
in this period I am studying the Spring MVC showcase example. Now I am
I am studing the Spring MVC showwcase dowloadable from the STS dashboard. Now I
In this period I am studying the Sping MVC showcase example dowlodable form STS
I know that there have been plenty of topics describing this topic but 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.