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

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

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

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

GenericDao

  1. public interface GenericDao

}

GenericDaoImpl

  1. @Transactional
  2. public class GenericDaoImpl

ClientDao

  1. public interface ClientDao extends GenericDao

ClientDaoImpl

  1. @Transactional
  2. @Repository("clientDao")
  3. public class ClientDaoImpl extends GenericDaoImpl

application context.xml

最佳答案
使用:

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

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

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

猜你在找的Spring相关文章