我正在使用 Spring 3 和 Hibernate 4
我有以下类结构
public interface GenericDAO<T> {
public void create(T entity);
public void update(T entity);
public void delete(T entity);
}
DAO 类
public interface EmployeeDAO extends GenericDAO<Employee> {
public void findEmployee(EmployeeQueryData data);
}
DAO 实现类
@Repository("employeeDAO")
public abstract class EmployeeDAOImpl implements EmployeeDAO {
protected EntityManager entityManager;
@Override
public void findEmployee(EmployeeQueryData data) {
...... code
}
我面临的问题是当我尝试部署时,出现以下异常。如果我abstract
从中EmployeeDAOImpl
删除并从中删除extends GenericDAO<Employee>
,EmployeeDAO
则应用程序将被部署而没有错误。所以不可能有abstract
类,EmployeeDAOImpl
或者我需要在没有的GenericDAO
情况下实现DAO实现中的所有方法abstract
?
Error creating bean with
name 'employeeService': Injection of autowired dependencies failed; \
nested exception is org.springframework.beans.factory.BeanCreationException:
Could not autowire field: test.dao.EmployeeDAO
test.service.EmployeeServiceImpl.employeeDAO; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException:
No matching bean of type [test.dao.EmployeeDAO] found for dependency:
expected at least 1 bean which qualifies as autowire candidate for
this dependency. Dependency annotations:
{@javax.inject.Inject()}.
编辑 1
通用DAOImpl
public class GenericDAOImpl<T> implements GenericDAO<T> {
public void create(T entity) {
}
public void update(T entity) {
}
public void delete(T entity) {
}
EmployeeDAOImpl
public class EmployeeDAOImpl extends GenericDAOImpl<Employee> implements EmployeeDAO {