File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

autowiring byName in spring

 
deepak carter
Ranch Hand
Posts: 165
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried calling your set and get method setAddress and getAddress and the parameter for setAddress(Address address)

?

Mark
 
Kathleen Angeles
Ranch Hand
Posts: 123
Firefox Browser Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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]
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic