我正在使用 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/