gpt4 book ai didi

java - 数组索引越界 : index0

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:22:23 26 4
gpt4 key购买 nike

我有以下代码:

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: Error creating bean with name 'planManagementController': Unsatisfied dependency expressed through field 'planService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'planServiceImpl': Unsatisfied dependency expressed through field 'planRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'planRepository': Invocation of init method failed; nested exception is java.lang.IndexOutOfBoundsException: Index: 0

如果我删除它:

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

服务器加载非常好。

如何解决这个问题?

最佳答案

当您组合 MongoRepository 和 customRepository (CustomPlanRepository) 时,您必须实现 CustomRepository 接口(interface) (CustomPlanRepositoryImpl)。 Spring 无法创建此实现。

public class CustomPlanRepositoryImpl implements CustomPlanRepository {
@Autowired
private MongoTemplate mongoTemplate;

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

}

关于java - 数组索引越界 : index0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52366834/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com