File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes autowiring byName in spring Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "autowiring byName in spring" Watch "autowiring byName in spring" New topic

autowiring byName in spring

deepak carter
Ranch Hand

Joined: Feb 19, 2011
Posts: 165
I am just starting up with Spring and trying autowiring byName here is my code

When i am trying to do autowring by name which states thats if name of property matches with name of name it will get autowired.however in my case its not happening. its giving me null with this...can anyone help me this this so that it be autowired correctly
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Have you tried calling your set and get method setAddress and getAddress and the parameter for setAddress(Address address)



Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Kathleen Angeles
Ranch Hand

Joined: Aug 06, 2012
Posts: 123

What Mark said will fix it.

Here is the reason behind it. Below is from Spring Framework 3.0.7 Reference.

Table 3.2. Autowiring modes
Mode: byName
Autowiring by property name. Spring looks for a bean with the same name as the property that needs to be autowired. For example, if a bean definition is set to autowire by name, and it contains a master property (that is, it has a setMaster(..) method), Spring looks for a bean definition named master, and uses it to set the property.

- k

[SpringSource Certified Spring Professional - Practice Tests]
I agree. Here's the link:
subject: autowiring byName in spring
It's not a secret anymore!