4

From docs:

In the client class containing the method to be injected (the CommandManager in this case), the method that is to be 'injected' must have a signature of the following form:

<public|protected> [abstract] <return-type> theMethodName(no-arguments);

Does exists way to workaround this limitation?

ChristopheD
  • 112,638
  • 29
  • 165
  • 179
user710818
  • 23,228
  • 58
  • 149
  • 207
  • What would you want Spring to do with the arguments of the method? – JB Nizet Apr 28 '12 at 17:08
  • Try [this](http://forum.springsource.org/showthread.php?32785-Lookup-method-injection-with-parameters). It's old, but contains useful pointers. – Marko Topolnik Apr 28 '12 at 17:09
  • Check selected answer here http://stackoverflow.com/questions/5349362/spring-bean-initialization-with-multiple-arg-method It worked for me. – Deeps Apr 12 '16 at 18:26

1 Answers1

3

Yes you can. Here is an example from the spring docs, http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html

 @Autowired
 public void prepare(MovieCatalog movieCatalog,
                   CustomerPreferenceDao customerPreferenceDao) {
   this.movieCatalog = movieCatalog;
   this.customerPreferenceDao = customerPreferenceDao;
 }
Bruce Lowe
  • 6,063
  • 1
  • 36
  • 47
  • 1
    Isn't OP asking about lookup methods? It's literally the method that is getting injected via proxying, not a method being injected its arguments. – Marko Topolnik Apr 28 '12 at 17:07
  • mmm, the question was a little hard to understand. I thought I had the meaning of it...but reading your comment and re-reading the question, it sounds like you could be correct. – Bruce Lowe Apr 28 '12 at 17:19
  • How do you call such a method? WIth 0 arguments and then some magic in an overloaded method will get the beans/arguments from the context? – Hervian May 30 '22 at 13:50