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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:36:37+00:00 2026-06-15T23:36:37+00:00

Spring documentation defines @Component annotation in the following way: Indicates that an annotated class

  • 0

Spring documentation defines @Component annotation in the following way: “Indicates that an annotated class is a “component”. Such classes are considered as candidates for auto-detection when using annotation-based configuration and classpath scanning. “

This is concise, but it does not say a lot. I understand that @Component is used to indicate that a class lifecycle (creation/destruction) will be managed by Spring. The question I have: I need to use it only in classes that will be autowired somewhere (1) or do I also need to use it in classes that have autowired attributes (2)?

(1)

@Component
class B {
}

class A {

   // @Autowired
   B b;
}

(2)

@Component
class B {
}

@Component
class A {

  // @Autowired
  B b;
}
  • 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-15T23:36:38+00:00Added an answer on June 15, 2026 at 11:36 pm

    Well, strictly speaking you don’t have to use anywhere, you can define beans in XML like in the old days. Also you can use @Service or @Repository like in the old days. But back to your question:

    If your bean A is not annotated with @Component or otherwise known to the Spring context, it will never be created and managed by Spring. So you either have to use an annotation or define A in XML.

    This is true for B as well. If you want it to be a subject for autowiring, it must be known to Spring – either by annotation scanning or by XML.

    At the end of the day it doesn’t really matter whether you use XML, annotation or Java configuration. It’s important that both beans are known to application context.

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

Sidebar

Related Questions

The spring webflow documentation mentions that their way of adding messages to a flow
I'm trying to implement my first Spring MVC controller, following Spring documentation, some tutorials
Following the spring-security documentation: http://static.springsource.org/spring-security/site/docs/3.0.x/reference/ldap.html I am trying to set up ldap authentication (very
I was reading Spring 3.0 documentation and I came to the sentence - Annotation
I am in reference to the following Spring documentation: http://static.springsource.org/spring-data/data-jpa/docs/1.1.0.RELEASE/reference/html/#repositories.custom-behaviour-for-all-repositories I am trying to
So I've been following the Spring documentation, specifically this part, http://static.springsource.org/spring/docs/current/spring-framework-reference/html/beans.html#beans-factory-collaborators on Dependency Injection,
According to the Spring Documentation here : While HTTP defines these four methods, HTML
The Unity documentation states: if a class that developers instantiate using the Resolve method
If I have in one file the following: module Something class Resource # Defines
I want to use Spring 3 for validation. In the reference documentation, section 6.2

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.