数组索引越界:索引0

3

我有以下代码:

public interface CustomPlanRepository {
    void plansUpdate(Query query,Update update,Class classname,String Collection);  
}

@Repository
public interface PlanRepository extends MongoRepository<Plan, 
                                          Serializable>,CustomPlanRepository{

    Plan findById(String id);
}

在服务器启动期间,它会抛出以下异常:

org.springframework.beans.factory.UnsatisfiedDependencyException: 创建bean“planManagementController”时出错:无法满足field“planService”的依赖关系;嵌套异常是 org.springframework.beans.factory.UnsatisfiedDependencyException: 创建bean“planServiceImpl”时出现不满意的依赖项;无法满足field“planRepository”的依赖性;嵌套异常是 org.springframework.beans.factory.BeanCreationException: 创建bean“planRepository”时出错:“init”方法的调用失败; 嵌套异常是java.lang.IndexOutOfBoundsException:Index:0

如果我去掉这段内容:

void plansUpdate(Query query,Update update,Class classname,String Collection);

服务器完全正常。

如何解决这个问题?


你实现了PlanRepository(PlanRepositoryImpl)吗?能否发布一下代码? - Mr_Thorynque
CustomPlanRepository是否有继承Mango或其他存储库的存储库?还是您有自己的实现方式?请发布相关信息。 - mallikarjun
我在我的服务类中使用了自动装配PlanRepository@Mr_THORYNQUE - UTKARSH
1个回答

0
当您将MongoRepository和自定义存储库(CustomPlanRepository)结合使用时,必须实现CustomRepository接口(CustomPlanRepositoryImpl)。Spring无法创建此实现。
public class CustomPlanRepositoryImpl implements CustomPlanRepository {
    @Autowired
    private MongoTemplate mongoTemplate;

     void plansUpdate(Query query,Update update,Class classname,String Collection){
    ....

     }

不要将您的最终autowired与PlanReposity接口更改。 - Mr_Thorynque

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接