[英]org.postgresql.util.PSQLException: ERROR: relation “bug_report_model” does not exist
I'm trying to run a simple java play 2.5 app on heroku. 我正在尝试在heroku上运行一个简单的Java Play 2.5应用程序。 I am able to open the home page which generally means that connection to the database is successful. 我能够打开主页,这通常意味着成功连接到数据库。 But when ever i try to call the route to add a dummy value to the table it shows 但是,当我尝试调用路由向表中添加虚拟值时,它会显示
play.api.UnexpectedException: Unexpected exception[PersistenceException: ERROR executing DML bindLog[] error[ERROR: relation "bug_report_model" does not exist\n Position: 13]]
The code to add a value to the database is 向数据库添加值的代码是
public Result enterDummyTextInDb() {
BugReportModel model = new BugReportModel();
model.save();
return ok(Json.toJson(model));
}
The Model class is 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;
}
} }
found something for spring/hibernate that said that the table isnt created and so we have to add 为spring / hibernate找到了一些东西,说该表未创建,因此我们必须添加
spring.jpa.hibernate.ddl-auto=create
but not sure about it for java play 2.5 但对于Java play 2.5不确定
You need to configure your app to run evolutions by making your Procfile like this: 您需要通过使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}
For more info see https://www.playframework.com/documentation/2.5.x/ProductionHeroku 有关更多信息,请参见https://www.playframework.com/documentation/2.5.x/ProductionHeroku
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.