我有以下代码:
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.UnsatisfiedPendencyException:异常:
创建名为“planmanagementcontroller”的bean时出错:未满足
通过字段“planservice”表示的依赖关系;嵌套异常为
org.springframework.beans.factory.UnsatisfiedPendencyException:异常:
创建名为“planserviceimpl”的bean时出错:未满足
通过字段“PlanRepository”表示的依赖关系;嵌套异常
是org.springframework.beans.factory.beancreationexception:错误
创建名为“planrepository”的bean:调用init方法
失败;嵌套异常为java.lang.IndexOutboundsException:
索引:0
如果我删除此:
void plansUpdate(Query query,Update update,Class classname,String Collection);
服务器负载非常好。
怎么解决这个问题?
最佳答案
当您将mongorepository和customrepository(customplanpresitory)结合起来时,必须实现customrepository接口(customplanpresitoryimpl)。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/