java - 数组索引超出范围:index0
问题描述
我有以下代码:
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:创建名为“planManagementController”的bean时出错:通过字段“planService”表示不满足的依赖关系;嵌套异常是 org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为“planServiceImpl”的 bean 时出错:通过字段“planRepository”表示不满足的依赖关系;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名为“planRepository”的 bean 时出错:调用 init 方法失败;嵌套异常是 java.lang.IndexOutOfBoundsException: Index: 0
如果我删除这个:
void plansUpdate(Query query,Update update,Class classname,String Collection);
服务器加载得很好。
如何解决这个问题?
解决方案
当您结合 MongoRepository 和 customRepository (CustomPlanRepository) 时,您必须实现 CustomRepository 接口 (CustomPlanRepositoryImpl)。Spring 无法创建此实现。
public class CustomPlanRepositoryImpl implements CustomPlanRepository {
@Autowired
private MongoTemplate mongoTemplate;
void plansUpdate(Query query,Update update,Class classname,String Collection){
....
}
推荐阅读
- vue.js - 如何使用 Nuxt/Vue 在页面重新加载时更新组件状态?
- cookies - WIX 在重新加载时自动重置 cookie
- arrays - 为什么 sscanf 只读取两行带有指针的指针?
- javascript - 如何更改 JavaScript 中的基本 URL?
- javascript - 使用 Jest 单元测试模拟代码中的条件
- apache-flink - HttpAsyncClient HC5 请求超时
- python - 如何使用 python 请求模块创建自定义标头
- arangodb - 如何在访客机器上访问 ArangoDB Web 界面
- python - 用数字上的数字对字符串列表进行排序
- java - Spring Junit 测试,@Configuration bean 不会在测试之间缓存