Spring data jpa Crud存储库是否具有有效的saveAll方法?

Spring data jpa Crud存储库是否具有有效的saveAll方法?,spring-data-jpa,Spring Data Jpa,我正试图在我的开发项目中使用Crudepository。我在许多文章中看到CRUD存储库确实支持saveAll方法,该方法允许在数据库中保存对象列表。但当我使用它时,它给了我一个错误,即未找到saveAll属性 下面是详细的错误 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'BinaryPartCRUDRepository': Invocation of init m

我正试图在我的开发项目中使用Crudepository。我在许多文章中看到CRUD存储库确实支持saveAll方法,该方法允许在数据库中保存对象列表。但当我使用它时,它给了我一个错误,即未找到saveAll属性 下面是详细的错误

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'BinaryPartCRUDRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query method public abstract java.util.List xxx.xxx.xx.xxxx.repository.BinaryPartCRUDRepository.saveAll(java.util.List)! No property saveAll found for type BinaryPart!
这是我的密码

       public interface BinaryPartCRUDRepository extends CrudRepository<BinaryPart, Long> {
       BinaryPart save(BinaryPart binaryPart);
       List<BinaryPart> saveAll(List<BinaryPart> binaryParts);
    }
公共接口二进制PartCrudepository扩展了Crudepository{
二进制部件保存(二进制部件二进制部件);
列出saveAll(列出二进制部件);
}
保存功能正在运行。但saveAll并非如此。
我还尝试使用持久性管理器进行批量保存。但是在进行JUnit测试时使用空对象。因此,我更愿意留在CRUD存储库中。谢谢你的建议

saveAll方法具有以下签名:

    <S extends T> Iterable<S> saveAll(Iterable<S> entities);
Iterable saveAll(Iterable实体);
您可以使用相同的名称定义另一个方法,但签名不同。Spring数据不知道如何为此创建实现,并抛出异常

只需将界面更改为:

public interface BinaryPartCRUDRepository extends CrudRepository<BinaryPart, Long> {}
公共接口二进制PartCrudepository扩展了Crudepository{}

您可以开始了。

saveAll
已经存在于
crudepository
中,因此无需为存储库界面中的saveAll指定您自己的方法

删除此部分:

List<BinaryPart> saveAll(List<BinaryPart> binaryParts);
List saveAll(列出二进制部件);

在服务类中,直接调用` saveAll方法。记住这个方法使用iterable作为参数和返回值。

不,它不是。safeeul在接口中声明了其他方法。我在Spring Boot 1中没有看到
crudepository::saveAll
,但显示了
save(Iterable)