• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Strange dependency injection goings on

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looking at this example in more detail and trying tofigure out how this works.
see http://static.springsource.org/docs/Spring-MVC-step-by-step/part5.html

My question is ... in the class JdbcProductDaoTests, how is the method


actually called?
I can see in the test-context that the bean definition is declared as

However, here's the puzzler, if I rename the method to setProductDaoXXX it still works, but if I call it xxsetProductDao it can't resolve which method to call when building the context.
 
author & internet detective
Posts: 41502
881
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
James,
By convention, setters begin with setXXX. When you renamed the method to xxsetProductDao(), it becomes just a random method and not a setter. This makes sense. Spring shouldn't have to look at every single method for dependency injection. Only the constructors and setters.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic