Spring Boot应用程序中缺少entityManagerFactory

问题描述 投票:0回答:1

我有以下问题:

projects.todolistapp.service.TodoItemServiceImpl中的todoItemRepository字段需要一个名为'entityManagerFactory'的bean,无法找到。注入点具有以下注释:-@ org.springframework.beans.factory.annotation.Autowired(必填= true)行动:考虑在配置中定义一个名为'entityManagerFactory'的bean。

我试图从.m2文件中删除所有存储库,并添加了Hibernate Core依赖关系,但是没有用。

您可以分叉我的整个应用,以便通过以下方式自行检查:https://github.com/ladrixx/webbapp

java mysql spring jpa entitymanager
1个回答
0
投票

我不明白为什么要定义SessionFactory。 Spring Boot根据您的application.properties自动配置DataSource。如果要自定义配置,可以看到here。尝试使用WebConfig类中的SessionFactory删除@Bean定义,然后尝试运行。

© www.soinside.com 2019 - 2024. All rights reserved.