By default,  there can only be one implementation in the application context to 
use wired by type.  However,  there is a way to mark an implementation as 
primary via annotation or XML (if the bean is defined via XML).



Sent from my mobile device

 -----Original Message-----
From:   Zhenhua (Gerald) Guo [mailto:[email protected]]
Sent:   Sunday, May 01, 2011 05:37 PM Eastern Standard Time
To:     [email protected]
Subject:        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

Reply via email to