File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "autowiring byName in spring" Watch "autowiring byName in spring" New topic
Author

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
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

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

?

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
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: http://aspose.com/file-tools
 
subject: autowiring byName in spring