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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:25:27+00:00 2026-05-28T06:25:27+00:00

In Spring 3.0.x documentation its mentioned that when you use other than setter/config method

  • 0

In Spring 3.0.x documentation its mentioned that when you use other than setter/config method for dependency injection ie.Property or Constructor then it should be declared as private not public

Eg. class Abc

{

@Autowired
private Def def;     //DEF may be a class or an Interface.
...
....

}

but i was trying with Spring 2.5.5 and tried to make it Public and it worked…n i could not figure out why it worked though it must have behaved in weired sense like Exception thrown

I am a newbie with Spring Dependency and pls do tell me any resource other the spring’s website where i can get good examples to learn Spring DI

  • 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-28T06:25:28+00:00Added an answer on May 28, 2026 at 6:25 am

    You mis-read the documentation. The page at the link you provided says:

    Only one constructor (at max) of any given bean class may carry this annotation, indicating the constructor to autowire when used as a Spring bean. Such a constructor does not have to be public.

    Fields are injected right after construction of a bean, before any config methods are invoked. Such a config field does not have to be public.

    Config methods may have an arbitrary name and any number of arguments; each of those arguments will be autowired with a matching bean in the Spring container. Bean property setter methods are effectively just a special case of such a general config method. Such config methods do not have to be public.

    At no point does it say " it should be declared as private not public". Indeed, the documentation doesn’t mention the word "private" at all.

    In other words, Spring doesn’t care what the visibility of the constructor, method or field is.

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

Sidebar

Related Questions

I'm reading the jQuery load documentation and it mentions that I can use load
I am reading spring through its official documentation and at one place I came
The documentation says that camel-spring-ws(v2.7.1) officially supports spring-ws 1.5.9, but doesn't mention spring-ws 2.0.2.RELEASE.
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
Spring.NET is an open source application framework that makes building enterprise .NET applications easier.
Spring IoC container gives you an option of replacing a method of a bean.
I'm trying to make Spring automatically register my remote destinations by reading its annotations.
Currently I have a custom form login page in Spring Security 3 that sends
Is there a built-in function/method that can check if a given string is a
Referencing Spring documentation : Any RuntimeException will trigger rollback, and any checked Exception will

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.