Java org.postgresql.util.PSQLException:错误:关系;错误报告模型;不存在
我正在尝试在heroku上运行一个简单的java play 2.5应用程序。我能够打开主页,这通常意味着连接到数据库是成功的。但是,当我试图调用route向它显示的表中添加一个伪值时Java org.postgresql.util.PSQLException:错误:关系;错误报告模型;不存在,java,postgresql,heroku,playframework,sbt,Java,Postgresql,Heroku,Playframework,Sbt,我正在尝试在heroku上运行一个简单的java play 2.5应用程序。我能够打开主页,这通常意味着连接到数据库是成功的。但是,当我试图调用route向它显示的表中添加一个伪值时 play.api.UnexpectedException: Unexpected exception[PersistenceException: ERROR executing DML bindLog[] error[ERROR: relation "bug_report_model" does not exist
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));
}
模型类是
@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;
}
但对于java play 2.5,您还不确定,您需要通过如下方式配置应用程序以运行演进:
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}
有关更多信息,请参见数据库中是否存在“缺陷报告模型”表?也许它被称为其他东西?数据库中现在没有表。就像我最后提到的。找到了与spring/hibernate相关的内容,但无法确定如何在java play中创建db。在入门scala play heroku代码中找到了一些东西,但不确定如何在java中实现它
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}