spring-data-jpa - Spring 数据jpa : No property flush found for type void

标签 spring-data-jpa

我正在使用 Spring Data JPA 开发 Spring MVC 应用程序。我构建了一个 JPA 存储库。

public interface AccessReportRepository extends JpaRepository<AccessReport, Long> {    
}

我还在我的项目中使用 Spring Data Mongo 和 JPA。

当我运行该项目时,出现此错误。

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lastDateController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.innolabmm.software.mongotest.springrest.ReadingService com.innolabmm.software.mongotest.springrest.LastDateController.readingService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'readingService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.innolabmm.software.mongotest.springrest.AccessReportRepository com.innolabmm.software.mongotest.springrest.ReadingService.reportRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accessReportRepository': FactoryBean threw exception on object creation; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property flush found for type void

有人知道发生了什么事吗?如果这有助于解决问题,我准备提供更多信息。提前致谢。

最佳答案

你使用Spring Boot吗?

当我尝试在 Spring Boot 应用程序中一起使用 JPA 和 Mongo 时,抛出了相同的异常。我发现存储库总是由 JPA 和 Mongo 解释,导致出现问题,因为我的存储库专门扩展了 JpaRepository

我只想生成 JPA 存储库,因此将以下内容添加到应用程序入口点。

@EnableAutoConfiguration(exclude={MongoRepositoriesAutoConfiguration.class})

关于spring-data-jpa - Spring 数据jpa : No property flush found for type void,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17400059/

相关文章:

java - 扩展实体类的非实体类

java - 使用 spring data jpa 在启动时将数据保存到数据库

mysql - 如何解决Hibernate "ERROR o.h.e.jdbc.spi.SqlExceptionHelper - Duplicate entry "异常

java - Spring Data Jpa 保存测试失败

java - @Valid 对象图验证不适用于 JPA 和 TraversableResolver

java - Spring 中使用 AOP @AfterReturning 出现意外的RollbackException

java - Spring 数据 : How to lock a row in a transaction and make other transactions wait until it is released?

java - Spring Web应用程序+ Hibernate问题: Unsatisfied dependency expressed through field

java - 当@OneToMany和@ManyToOne双向链接时,关联实体的保存不正确

java - 如何使用外键类型从 jpa 存储库返回选择查询