You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rave.apache.org by "Zhenhua (Gerald) Guo" <je...@gmail.com> on 2011/05/01 23:37:24 UTC

question regarding DI in Spring

I am new to Spring.  I read our RAVE code, and I got a question
regarding how Dependency Injection is done.  I've used Guice (another
DI framework) before so I have background of DI.  In Spring,
@Autowired can be used to tell Spring framework that the related
property needs to be injected when needed.  Autowiring can be done in
several ways: by name, by type, etc.  I wonder how "Autowire by type"
works.  For example, suppose there is an interface called UserService
and several implementations called RegularUserService, VIPUserService,
etc.  How could I tell Spring which implementation to use when a
property is injected whose type is UserService?  FYI in Guice,
@ImplementedBy does the job.

Thanks

Gerald