I have created a service:
package tn.ett.medial.service;
@Service
public class ExchangeService {
private Currency EURCurrency;
public Currency getEURCurrency() {
....
return EURCurrency;
}
and a component
package tn.ett.medial.utils.dto;
@Component
public class ProductDTO implements Serializable {
@Autowired
ExchangeService exchangeService;
public ProductDTO() {
}
public ProductDTO(Product product){
System.out.println("service****" + exchangeService);
Currency EURCurrency = exchangeService.getEURCurrency();
}
}
I added the component-scan tag in my application context
<context:component-scan base-package="tn.ett.medial" />
Why the exchangeService is null? (although it works when I inject it into a @Controller).