【问题标题】:How to rectify spring boot entity manager factory?如何整顿spring boot实体管理器工厂?
【发布时间】:2021-07-12 05:25:50
【问题描述】:

我是 Spring Boot 应用程序的新手,我遇到了与某些实体管理器工厂相关的问题。我正在尝试在 localhost 上运行我的应用程序。我在下面附上了一张错误图片:

【问题讨论】:

    标签: spring-boot hibernate spring-mvc jpa jdbc


    【解决方案1】:

    这个错误是因为在类路径中没有找到数据库依赖,所以没有创建 entityManagerFactory bean。

    如果您添加一个 DB 依赖项,例如 H2(在内存 DB 中),spring 会在类路径中检测到它并创建丢失的 bean。

     <dependency>
                    <groupId>com.h2database</groupId>
                    <artifactId>h2</artifactId>
                    <scope>runtime</scope>
     </dependency>
    

    您可以添加您想要的数据库依赖项(mysql、postgres 等),为了示例,我添加了 H2。

    【讨论】:

    • 好的,是的,我找到了。这是缺失的。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2013-05-01
    • 1970-01-01
    • 2019-05-25
    • 2010-11-21
    • 2012-03-14
    • 1970-01-01
    • 2015-09-01
    • 2014-05-20
    相关资源
    最近更新 更多