Hi,
I'm using Spring 3.0.4 and trying to autowire a service by retrieving the @Qualifier value from a placeholder(a property file). This way i can switch between the Real service implementation and the mock implementation, just by changing the value in the property file. By doing so i want to avoid recompilation of code.
Below is my sample codes :
Integration Layer
Interface:
Code:public interface Service { ....... }
Mock Implementation :
Code:@Service("mockService") public class MockService implements Service { ....... }
Real-Service Implementation :
Code:@Service("realService") public class ServiceImpl implements Service { ....... }
Business Service Layer
Autowire service:
Code:..... @Autowired @Qualifier("${service.real}") private Service service; .....
qualifier.properties:
Code:..... service.real=mockService .....
The above idea is to change the service.real value to service.real, by doing so i can switch from Mock implementation to Real Implementation.
During server startup it fails and message is displayed saying no bean found with name: ${service.real}
Any Idea how to resolve this issue or alternate way to achieve this functionality using @Qualifier ?


Reply With Quote
