I have three Maven modules :
- Dao (containing DAO interfaces),
- DaoImpl (containing DAO classes implementing Dao),
- Service (containing services using DaoImpl objects).
The dependencies between the three modules are like this :
DaoImpl -> Dao <- Service
‘->’ means ‘depends on’
I’d like to inject DaoImpl beans into Service beans. The problem is that since Service is not depending on DaoImpl, it can’t access its classpath. Hence, the DaoImpl beans declared in Service can’t be autowired to the beans declared in the application context of DaoImpl.
One solution is to make Service dependent on DaoImpl.
Dao <- DaoImpl <- Service
But in this cas, there will be no meaning of having interfaces for the DAOs. The module Dao will be no longer required and DaoImpl will be exposed.
Do you have any arguments about this subject?
Best regards.
IMHO you should introduce fourth module which depends on dao, (one of) daoimpl, and service.
It’s sort of ‘application deployment’ module – typically WAR or something similar.
The role of the Application module is primarily to prepare the complete classpath.