簡體   English   中英

org.postgresql.util.PSQLException:錯誤:關系“ bug_report_model”不存在

[英]org.postgresql.util.PSQLException: ERROR: relation “bug_report_model” does not exist

我正在嘗試在heroku上運行一個簡單的Java Play 2.5應用程序。 我能夠打開主頁,這通常意味着成功連接到數據庫。 但是,當我嘗試調用路由向表中添加虛擬值時,它會顯示

play.api.UnexpectedException: Unexpected exception[PersistenceException: ERROR executing DML bindLog[] error[ERROR: relation "bug_report_model" does not exist\n   Position: 13]]

向數據庫添加值的代碼是

 public Result enterDummyTextInDb() {
    BugReportModel model = new BugReportModel();
    model.save();
    return ok(Json.toJson(model));
}

Model類是

@Entity
public class BugReportModel extends Model {
@Id
private Long id;
private Long timestamp = System.currentTimeMillis();

public BugReportModel() {
}

public static Finder<Long, BugReportModel> find = new Model.Finder<Long, BugReportModel>(BugReportModel.class);

public static List<BugReportModel> findAll() {
    return BugReportModel.find.orderBy("id").findList();
}


public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

public Long getTimestamp() {
    return timestamp;
}

public void setTimestamp(Long timestamp) {
    this.timestamp = timestamp;
}

}

為spring / hibernate找到了一些東西,說該表未創建,因此我們必須添加

spring.jpa.hibernate.ddl-auto=create 

但對於Java play 2.5不確定

您需要通過使Procfile像這樣配置您的應用程序以運行演進:

web: target/universal/stage/bin/myapp -Dhttp.port=${PORT} -Dplay.evolutions.db.default.autoApply=true -Ddb.default.driver=org.postgresql.Driver -Ddb.default.url=${DATABASE_URL}

有關更多信息,請參見https://www.playframework.com/documentation/2.5.x/ProductionHeroku

暫無
暫無

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

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