表达不满意的依赖性

时间:2018-04-03 05:37:09

标签: java spring spring-boot

我有一些课程如下

public abstract interface IGenRepository  <T> {

 public abstract List<T> getAll(String filter);
}

@Repository
public abstract class GenRepository<T> implements IGenRepository<T> {
protected abstract Class<T> myFunction();
 @Override
public List<T> getAll(String filter) {

.......}}

所有这些类都是通用的,现在我想在我的项目中使用这些类

public  interface IProductRepository extends IGenRepository<Product> {}

并且这个课程是:

@Repository
public class ProductRepository extends GenRepository<Product> {}

在使用此类时:

@Autowired private IProductRepository iProductRepository;

有此错误

Exception encountered during context initialization - cancelling refresh attempt: 
org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'productService': Unsatisfied dependency expressed through field 'iProductRepository'; 
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: 
No qualifying bean of type 'org.tax.repositories.IProductRepository' available:
expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: 
 {@org.springframework.beans.factory.annotation.Autowired(required=true)}

1 个答案:

答案 0 :(得分:1)

您没有实施IProductRepository ProductRepository课程。 更改代码如下 -

@Repository
public class ProductRepository implements IProductRepository extends GenRepository<Product> {}