【问题标题】:Field repository in com.App.Shopping.model.service.UserServiceImpl required a bean named 'entityManagerFactory' that could not be foundcom.App.Shopping.model.service.UserServiceImpl 中的字段存储库需要一个名为“entityManagerFactory”的 bean,但无法找到
【发布时间】:2020-08-30 12:47:06
【问题描述】:

。 ____ _ __ _ _ /\ / ' __ _ () __ __ _ \ \ \
( ( )_
_ | '_ | '| | ' / ` | \ \ \
\/ __)| |)| | | | | || (
||))))) ' || .__|| ||| |_, | / / / / =========||===============|/=//// :: Spring Boot :: (v2.3.3.RELEASE)

2020-08-30 18:09:53.081 INFO 4536 --- [restartedMain] com.App.Shopping.ShoppingApplication:在 PID 4536 的 DESKTOP-DSCQJON 上启动 ShoppingApplication (D:\sarat\eclipse-workspace\Shopping. zip_expanded\Shopping\target\classes 在 D:\sarat\eclipse-workspace\Shopping.zip_expanded\Shopping 中由 sarat 启动 2020-08-30 18:09:53.081 INFO 4536 --- [restartedMain] com.App.Shopping.ShoppingApplication:未设置活动配置文件,回退到默认配置文件:默认 2020-08-30 18:09:53.148 INFO 4536 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate:在默认模式下引导 Spring Data JPA 存储库。 2020-08-30 18:09:53.151 INFO 4536 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate:在 3 毫秒内完成 Spring 数据存储库扫描。找到 1 个 JPA 存储库接口。 2020-08-30 18:09:53.256 INFO 4536 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer:Tomcat 使用端口初始化:8083 (http) 2020-08-30 18:09:53.256 INFO 4536 --- [restartedMain] o.apache.catalina.core.StandardService:启动服务 [Tomcat] 2020-08-30 18:09:53.256 INFO 4536 --- [restartedMain] org.apache.catalina.core.StandardEngine:启动 Servlet 引擎:[Apache Tomcat/9.0.37] 2020-08-30 18:09:53.325 INFO 4536 --- [restartedMain] org.apache.jasper.servlet.TldScanner:至少有一个 JAR 已扫描 TLD,但未包含 TLD。启用此记录器的调试日志记录以获取已扫描但未在其中找到 TLD 的 JAR 的完整列表。在扫描期间跳过不需要的 JAR 可以缩短启动时间和 JSP 编译时间。 2020-08-30 18:09:53.327 INFO 4536 --- [restartedMain] o.a.c.c.C.[Tomcat-24].[localhost].[/]:初始化 Spring 嵌入式 WebApplicationContext 2020-08-30 18:09:53.327 INFO 4536 --- [restartedMain] w.s.c.ServletWebServerApplicationContext:根 WebApplicationContext:初始化在 244 毫秒内完成 2020-08-30 18:09:53.339 WARN 4536 --- [restartedMain] ConfigServletWebServerApplicationContext:上下文初始化期间遇到异常-取消刷新尝试:org.springframework.beans.factory.UnsatisfiedDependencyException:创建名为“shoppingController”的bean时出错:不满意通过字段“userservice”表达的依赖关系;嵌套异常是 org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为“userServiceImpl”的 bean 时出错:通过字段“repository”表示的依赖关系不满足;嵌套异常是 org.springframework.beans.factory.BeanCreationException:在 ShoppingApplication 上声明的 @EnableJpaRepositories 中定义的 com.App.Shopping.model.repository.UserRepository 中创建名称为“userRepository”的 bean 时出错:无法创建内部 bean '(内部 bean )#71a2245c' 类型为 [org.springframework.orm.jpa.SharedEntityManagerCreator],同时设置 bean 属性 'entityManager';嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名称为“(内部 bean)#71a2245c”的 bean 时出错:设置构造函数参数时无法解析对 bean 'entityManagerFactory' 的引用;嵌套异常是 org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available 2020-08-30 18:09:53.340 INFO 4536 --- [restartedMain] o.apache.catalina.core.StandardService:停止服务 [Tomcat] 2020-08-30 18:09:53.344 INFO 4536 --- [restartedMain] ConditionEvaluationReportLoggingListener:

启动 ApplicationContext 时出错。要显示条件报告,请在启用“调试”的情况下重新运行您的应用程序。 2020-08-30 18:09:53.400 错误 4536 --- [restartedMain] o.s.b.d.LoggingFailureAnalysisReporter:


应用程序启动失败


说明:

com.App.Shopping.model.service.UserServiceImpl 中的字段存储库需要一个名为“实体管理器工厂”的 bean,但无法找到。

注入点有以下注解: - @org.springframework.beans.factory.annotation.Autowired(required=true)

行动:

考虑在您的配置中定义一个名为“实体管理器工厂”的 bean。

【问题讨论】:

  • 当我启动应用程序时出现错误,任何人都可以帮助我

标签: spring-boot


【解决方案1】:

我可以从堆栈跟踪中看到您的 entitymanagerfactory 不可用。

您是否尝试在 UserServiceImpl 中按名称自动装配,这意味着您是否添加了 Qualifier 注释?

【讨论】:

  • 不,我没有使用限定符注释
猜你喜欢
  • 2019-02-23
  • 2017-06-30
  • 2019-02-13
  • 2020-01-24
  • 2018-03-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-14
  • 2021-04-14
相关资源
最近更新 更多