我正在嘗試學習 Quarkus,但在添加 JPA 依賴項后,應用程式不再初始化。
這是添加的依賴項:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
以下是我遇到的錯誤:
[org.tes.uti.TestcontainersConfiguration] (build-47) Attempted to read Testcontainers configuration file at file:/home/fhb/.testcontainers.properties but the file was not found. Exception message: FileNotFoundException: /home/fhb/.testcontainers.properties (No such file or directory)
之后 Quarkus 繼續運行并收到以下錯誤:
Caused by: java.lang.RuntimeException: io.quarkus.runtime.configuration.ConfigurationException: Model classes are defined for the default persistence unit <default> but configured datasource <default> not found: the default EntityManagerFactory will not be created. To solve this, configure the default datasource. Refer to https://quarkus.io/guides/datasource for guidance.
這是我的 application.properties 檔案:
quarkus.datasource.db-kind=postgresql
quarkus.datasource.username=postgres
quarkus.datasource.password=admin
quarkus.datasource..jdbc.url=jdbc:postgresql://localhost:5432/quarkus-social
quarkus.datasource.jdbc.max-size=16
我認為 Quarkus 正在嘗試運行測驗,為此它需要我從未創建過的.testcontainers.properties檔案。無論如何,我不想在 /home/fhb/ 中創建該檔案,所以有辦法指定該檔案位置嗎?
除此之外,我想知道 Testcontainers 是否與單元測驗有關,我想將其添加到我的 quarkus 應用程式中。
在此先感謝您的幫助。
uj5u.com熱心網友回復:
我想問題是一個小錯字。
從改變
quarkus.datasource..jdbc.url=jdbc:postgresql://localhost:5432/quarkus-social
到
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/quarkus-social
如果您不指定資料庫的 URL 并在devortest模式下運行,Quarkus 會使用測驗容器為您啟動一個資料庫。
quarkus.io/guides/datasource 上有教程。
關于測驗,您可以使用測驗容器或記憶體資料庫中的一個作為 H2。您可以在 Quarkus 指南上找到所有這些。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/432635.html
標籤:爪哇 PostgreSQL jpa 测试 夸库斯
