簡體   English   中英

如何解決此 Java Spring:entityManagerFactory 錯誤?

[英]How do I resolve this Java Spring: entityManagerFactory Error?

我正在嘗試運行我的 java spring 應用程序,但在構建時遇到以下錯誤:

Description:

Field productRepository in ch.turwaith.mhd_tracker_backend.ProductController required a bean named 'entityManagerFactory' that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)

數據庫連接已在 application.properties 文件中正確配置。 我不知道更多,我該如何解決這個問題? 請告訴我您需要查看哪些文件才能了解問題所在。

請嘗試使用 spring initializr 重新創建您的項目:

  • 添加 web 依賴
  • 添加 jpa 依賴
  • 添加驗證依賴
  • 添加 mysql 驅動程序
  1. pom.xml 依賴項將如下所示:
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>

        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM