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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:31:42+00:00 2026-05-15T05:31:42+00:00

Is it correct that I can put context:annotation-config in my XML config and it

  • 0

Is it correct that I can put context:annotation-config in my XML config and it will automatically inject the bean class without needing any annotations?

So instead of using these annotation types:

public class Mailman
{
    private String name;

    @Autowired
    private Parcel Parcel;

    public Mailman(String name)
    {
        this.name = name;
    }

    @Autowired
    public void setParcel(Parcel Parcel)
    {
        this.Parcel = Parcel;
    }

    @Autowired
    public void directionsToParcel(Parcel Parcel)
    {
        this.Parcel = Parcel;
    }

}

I would just need to write this:

<beans ... >
<bean id="mailMan" class="MailMan">
 <constructor-arg value="John Doe"/>
</bean>
<bean id="parcel" class="Parcel" />
<context:annotation-config />
</beans>

and then my MailMan class would look a lot simpler without the need for annotations:

public class Mailman
{
    private String name;

    private Parcel Parcel;

    public Mailman(String name)
    {
        this.name = name;
    }    
}
  • 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-15T05:31:42+00:00Added an answer on May 15, 2026 at 5:31 am

    By default, a Spring context will pay no attention to @Autowired annotations. In order to process them, the context needs to have a AutowiredAnnotationBeanPostProcessor bean registered in the context.

    <context:annotation-config/> registers one of these for you (along with a few others), so you do need it (unless you register AutowiredAnnotationBeanPostProcessor yourself, which is perfectly valid).

    If you don’t like having @Autowired in your code, then you can explicitly inject properties in the XML using <property>, which just moves the clutter from one place to another.

    If your context is extremely simple, then you can use implicit autowiring, as described here. Essentially, this tells Spring to autowire automatically by property name or type. This required very little configuration, but it very quickly gets out of control – it’s automatic nature means it’s hard to control, and gives you very little flexibility.

    @Autowired really is the best option, in general.

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

Sidebar

Related Questions

Is it correct to say that the parallel computation with iterative MapReduce can be
How can I correct the following so that I don't receive a syntax error
I'm new to Symfony. Is my understanding correct that the User class is actually
(1). When using C++ template, is it correct that the compiler (e.g. g++) will
The Context I have a custom template container class put together from a map
how i can put im2 in the correct place FrameLayout rv =(FrameLayout)findViewById(R.id.my_ph); ImageView im1
Is it correct that the reveal applescript command is broken with iTunes 9? Works:
My Visual Studio 2008 debugger is showing integers as hexadecimals, how to correct that?
Like in: u'Hello' My guess is that it indicates "Unicode", is that correct? If
Am I correct in assuming that if you have an object that is contained

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.