通过类型为[java.lang.Class]的索引0的构造函数参数表示的不满意的依赖性

前端之家收集整理的这篇文章主要介绍了通过类型为[java.lang.Class]的索引0的构造函数参数表示的不满意的依赖性前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

嗨,大家好我用hibernate和spring创建了一个简单的web应用程序,我想实现一个包含crud操作的抽象类,但是我有这个错误

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'clientService' defined in class path resource [applicationContext.xml]: 
Cannot resolve reference to bean 'clientDao' while setting bean property 'clientDao'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'clientDao' defined in class path resource [applicationContext.xml]: 
Unsatisfied dependency expressed through constructor argument with index 0 of type [java.lang.Class]: 

GenericDao

public interface GenericDao

}

GenericDaoImpl

@Transactional
public  class GenericDaoImpl

ClientDao

public interface ClientDao  extends GenericDao

ClientDaoImpl

@Transactional
@Repository("clientDao")
public class ClientDaoImpl extends GenericDaoImpl

application context.xml

最佳答案
使用:

Spring会将字符串“强制转换”为类.然后,您可以从XML中删除客户端bean.

或者从ClientDaoImpl中删除此参数,因为它没用(它只能是这种类型,因此没有理由将其作为参数)

public ClientDaoImpl() {
    super(com.xxx.Client.class);
}

猜你在找的Spring相关文章