I'm trying to make a Web Aplication with Spring, and my classes (Controllers and Services) are using Abstraction to avoid code repetition. Knowing that, this is my structure:
public abstract class AbstractController {
@Autowired
private AbstractService serviceAbs;
.
.
.
}
@Controller
@RequestMapping(value = "/webService")
public class Service1Controller extends AbstractController {
@Autowired
Service1Service service;
@RequestMapping(value = { "..." })
public final ModelAndView addService(...) {
}
.
.
.
}
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
public class AbstractService {
@Autowired
protected ServiceDAO serviceDAO;
public final ModelAndView addService(...) {
}
.
.
.
}
@Service
public class Service1Service extends AbstractService {
.
.
.
}
This works fine, but when I try to add another child to the AbstractService, the Spring can't work, even when I use Qualifier anotation, I don't know what to do anymore. (I'm learning English yet, so sorry for any mistakes)
Actually, I need to make a generic instance of the abstract class, and then use the Qualifier annotation, so I created:
@Service
public class GenericService extends AbstractServiceService {
.
.
.
}
And then, at the abstractController I change the propertie:
@Autowired
@Qualifier("genericService")
private AbstractService serviceAbs;
Thanks to Basil Battikhi, his sugestion did make me seach about some other annotations.