1

I've tried to create a complex object by using spring's @Autowired annotation but it looks like it is not possible.

I'm trying to create two objects: View and Presenter, with prototype scopes and then inject their references to each other. What is more: I'd like to pass two additional parameters from the creator of the instance and inject some additional services from the IoC container.

In Guice it is possible via "assisted injection", but how can I achieve that in spring?

G. Demecki
  • 10,145
  • 3
  • 58
  • 58
  • 1
    See Java and XML based config in Spring. `@Autowired` cannot be used for complex configurations. – Abhinav Sarkar Sep 18 '12 at 06:41
  • What is your problem? it should work. Of course you need to attach the @Autowired annotation to the files (or setter) and not to the constructor. – Ralph Sep 18 '12 at 10:47
  • @Ralph No, it shouldn't. – G. Demecki Sep 18 '12 at 11:19
  • And why not? -- It seams that I do not understand your scenario. – Ralph Sep 18 '12 at 12:27
  • @Ralph Because circular dependencies with `@Autowired` generally works only for `Singleton` scope. In my case objects have `prototype` scope. – G. Demecki Sep 18 '12 at 13:57
  • @Gregory: i can not find any hint for `prototype` scope in your question. May you should impove you question with the relevant details! – Ralph Sep 18 '12 at 18:24

0 Answers0