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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:47:21+00:00 2026-05-15T12:47:21+00:00

Little confused, the basic spring mvc app has this: app-config.xml <context:component-scan base-package=org.springframework.samples.mvc.basic /> and

  • 0

Little confused, the basic spring mvc app has this:

app-config.xml

<context:component-scan base-package="org.springframework.samples.mvc.basic" />

and the mvc-config.xml has:

<!-- Configures the @Controller programming model -->
    <mvc:annotation-driven />
  1. Do you really need both?

  2. for component-scan, does this mean if I don’t put the correct package path my @Controller and @Service markers will have no effect?
    If I need more than one package, do I just duplicate the entry?

I tried using just the mvc:annotation-driven but that didn’t work, I had to put com.example.web.controllers in the component-scan xml node to make it work.

  • 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-15T12:47:22+00:00Added an answer on May 15, 2026 at 12:47 pm

    context:component-scan is clear

    Scans the classpath for annotated components that will be auto-registered as Spring beans. By default, the Spring-provided @Component, @Repository, @Service, and @Controller stereotypes will be detected.

    So @Controller is just a Spring bean. Nothing else.

    And

    mvc:annotation-driven

    registers the HandlerMapping and HandlerAdapter required to dispatch requests to your @Controllers

    Which is similar to

    <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
    <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
    

    If I need more than one package, do I just duplicate the entry?

    You can if you want. context:component-scan is just a bean post-processor.

    <context:component-scan base-package="br.com.app.view.controller"/>
    <context:component-scan base-package="br.com.app.service"/>
    

    Or

    Use a comma-separated list of packages to scan for annotated components.

    <context:component-scan base-package="br.com.app.view.controller,br.com.app.service"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There are two main problems The MIME type is text/javascript,… May 16, 2026 at 10:19 am
  • Editorial Team
    Editorial Team added an answer The repo size gets larger with every commit. But git… May 16, 2026 at 10:19 am
  • Editorial Team
    Editorial Team added an answer I would recommend splitting your web application where it makes… May 16, 2026 at 10:19 am

Trending Tags

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

Top Members

Related Questions

I'm a little confused as to how the model should 'work' in my basic
A little confused how to create a query and set a dynamic var in
I'm a little confused about CSS and the class attribute. I always thought, the
I am little confused with logical AND operator. I have these 2 lines of
I'm a little confused about the granularity offered by the HttpResponse.RemoveOutputCacheItem() call. I'm interested
Having a little bit of trouble with this section of code: if(!empty($_POST['RemoveRequest']) && isset($_POST['RemoveRequest'])){
This little search example works but only the first time. How do I clear
Wrote up a basic file handler for a Java Homework assignment, and when I
Hey, I was just writing another basic script for my JS & jQuery practice,
I am trying to figure out NSXMLParser for my iPhone app and while I

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.