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
You mis-read the documentation. The page at the link you provided says:
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.