应用程序在部署 Heroku Play 后崩溃!框架(double 类型不存在)
App crashed after deployment Heroku Play! Framework (type double does not exist)
我无法使用 PostgreSQL 数据库在 Heroku 上正确部署我的 Play Frmaework app
(Java)。
Procfile
web: target/universal/stage/bin/name -Dhttp.port=${PORT}
-DapplyEvolutions.default=true -Ddb.default.driver=org.postgresql.Driver -Ddb.default.url=$DATABASE_URL
built.sbt:
name := """name"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.1"
libraryDependencies ++= Seq(
javaJdbc,
javaEbean,
cache,
javaWs
)
libraryDependencies += "org.postgresql" % "postgresql" % "9.3-1100-jdbc4"
Heroku 的日志:
←[36m2015-05-20T13:35:43.429517+00:00 app[web.1]:←[0m @6m7pfofpb:
Database 'default' is in an inconsistent state!
←[36m2015-05-20T13:35:43.412967+00:00 app[web.1]:←[0m [←[31merror←[0m]
play - ERROR: type "double" does not exist
←[36m2015-05-20T13:35:43.412974+00:00 app[web.1]:←[0m Position: 320
[ERROR:0, SQLSTATE:42704] ←[36m2015-05-20T13:35:43.428889+00:00
app[web.1]:←[0m Oops, cannot start the server.
←[36m2015-05-20T13:35:43.429771+00:00 app[web.1]:←[0m at
play.api.db.evolutions.Evolutions$.checkEvolutionsState(Evolutions.scala:196)
←[36m2015-05-20T13:35:43.429822+00:00 app[web.1]:←[0m at
play.api.db.evolutions.Evolutions$.databaseEvolutions(Evolutions.scala:367)
←[36m2015-05-20T13:35:43.429871+00:00 app[web.1]:←[0m at
play.api.db.evolutions.Evolutions$$anonfun$evolutionScript.apply(Evolutions.scala:332)
←[36m2015-05-20T13:35:43.429907+00:00 app[web.1]:←[0m at
play.api.db.evolutions.Evolutions$$anonfun$evolutionScript.apply(Evolutions.scala:330)
←[36m2015-05-20T13:35:43.433005+00:00 app[web.1]:←[0m at
scala.Option.map(Option.scala:145)
←[36m2015-05-20T13:35:43.433063+00:00 app[web.1]:←[0m at
play.api.db.evolutions.Evolutions$.evolutionScript(Evolutions.scala:330)
←[36m2015-05-20T13:35:43.433140+00:00 app[web.1]:←[0m at
play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$$anonfun$apply.apply$mcV$sp(Evolutions.scala:486)
←[36m2015-05-20T13:35:43.433214+00:00 app[web.1]:←[0m at
play.api.db.evolutions.EvolutionsPlugin.withLock(Evolutions.scala:531)
←[36m2015-05-20T13:35:43.433254+00:00 app[web.1]:←[0m at
play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart.apply(Evolutions.scala:485)
←[36m2015-05-20T13:35:43.433294+00:00 app[web.1]:←[0m at
play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart.apply(Evolutions.scala:483)
←[36m2015-05-20T13:35:43.433333+00:00 app[web.1]:←[0m at
scala.collection.immutable.List.foreach(List.scala:383)
←[36m2015-05-20T13:35:43.433450+00:00 app[web.1]:←[0m at
play.api.db.evolutions.EvolutionsPlugin.onStart(Evolutions.scala:483)
←[36m2015-05-20T13:35:43.433528+00:00 app[web.1]:←[0m at
play.api.Play$$anonfun$start$$anonfun$apply$mcV$sp.apply(Play.scala:91)
←[36m2015-05-20T13:35:43.433588+00:00 app[web.1]:←[0m at
play.api.Play$$anonfun$start$$anonfun$apply$mcV$sp.apply(Play.scala:91)
←[36m2015-05-20T13:35:43.433638+00:00 app[web.1]:←[0m at
scala.collection.immutable.List.foreach(List.scala:383)
←[36m2015-05-20T13:35:43.433676+00:00 app[web.1]:←[0m at
play.api.Play$$anonfun$start.apply$mcV$sp(Play.scala:91)
←[36m2015-05-20T13:35:43.433728+00:00 app[web.1]:←[0m at
play.api.Play$$anonfun$start.apply(Play.scala:91)
←[36m2015-05-20T13:35:43.433774+00:00 app[web.1]:←[0m at
play.api.Play$$anonfun$start.apply(Play.scala:91)
←[36m2015-05-20T13:35:43.433809+00:00 app[web.1]:←[0m at
play.utils.Threads$.withContextClassLoader(Threads.scala:21)
←[36m2015-05-20T13:35:43.433864+00:00 app[web.1]:←[0m at
play.api.Play$.start(Play.scala:90)
←[36m2015-05-20T13:35:43.433912+00:00 app[web.1]:←[0m at
play.core.StaticApplication.(ApplicationProvider.scala:55)
←[36m2015-05-20T13:35:43.434109+00:00 app[web.1]:←[0m at
play.core.server.NettyServer$.createServer(NettyServer.scala:244)
←[36m2015-05-20T13:35:43.434194+00:00 app[web.1]:←[0m at
play.core.server.NettyServer$$anonfun$main.apply(NettyServer.scala:280)
←[36m2015-05-20T13:35:43.434302+00:00 app[web.1]:←[0m at
play.core.server.NettyServer$$anonfun$main.apply(NettyServer.scala:275)
←[36m2015-05-20T13:35:43.434388+00:00 app[web.1]:←[0m at
scala.Option.map(Option.scala:145)
←[36m2015-05-20T13:35:43.434467+00:00 app[web.1]:←[0m at
play.core.server.NettyServer$.main(NettyServer.scala:275)
←[36m2015-05-20T13:35:43.434565+00:00 app[web.1]:←[0m at
play.core.server.NettyServer.main(NettyServer.scala)
←[36m2015-05-20T13:35:44.389152+00:00 heroku[web.1]:←[0m State changed
from starting to crashed ←[36m2015-05-20T13:35:44.376937+00:00
heroku[web.1]:←[0m Process exited with status 255
我特别看不懂这行日志
00:00 app[web.1]:←[0m [←[31merror←[0m] play - ERROR: type "double"
does not exist
当然,我的一些项目有一些双重属性class。为什么double类型会出错?
任何 advice/ideas 欢迎 :)
编辑 1
这是我使用 double
类型的仅有的两个 classes。
汽车
@Entity
public class Car extends Model{
@Id
@GeneratedValue
private int id;
@ManyToOne
@JoinColumn(name="user_fk")
private User user;
private String brand;
private String model;
@Column(unique = true)
private String licencePlate;
private String fuel;
private int nbSits;
@Column(name = "avg_cons", columnDefinition = "REAL")
private double avgCons; // Average consumption
@Column(name = "co2_cons", columnDefinition = "REAL")
private double co2Cons;
@Column(name = "htva_price", columnDefinition = "REAL")
private double htvaPrice;
@Column(name = "leasing_price", columnDefinition = "REAL")
private double leasingPrice;
@Column(columnDefinition = "REAL")
private double mileage;
@Column(columnDefinition = "REAL")
private boolean availability;
}
交易
@Entity
@Table(name = "transactions")
public class Transaction extends Model{
@Id
@GeneratedValue
private int id;
@OneToOne
@JoinColumn(name = "car_fk")
private Car car;
@OneToOne
@JoinColumn(name = "driver")
private User driver;
@Column(name = "from_date")
private Timestamp fromDate;
@Column(name = "to_date")
private Timestamp toDate;
@Column(name = "start_mileage", columnDefinition = "REAL")
private double startMileage;
@Column(name = "end_mileage", columnDefinition = "REAL")
private double endMileage;
@Column(columnDefinition = "REAL")
private double avgCons;
private String status;
private boolean exchange;
}
PostgreSQL 使用列类型 double precision 并且不知道列类型 double
我建议尝试
@Column(columnDefinition = "NUMERIC")
private BigDecimal startMileage;
columnDefinition
的值实际上是 DDL 语句的一部分,这就是为什么您应该检查 1.sql 以查看究竟生成了什么(由 Ebean)
我无法使用 PostgreSQL 数据库在 Heroku 上正确部署我的 Play Frmaework app
(Java)。
Procfile
web: target/universal/stage/bin/name -Dhttp.port=${PORT} -DapplyEvolutions.default=true -Ddb.default.driver=org.postgresql.Driver -Ddb.default.url=$DATABASE_URL
built.sbt:
name := """name"""
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.1"
libraryDependencies ++= Seq(
javaJdbc,
javaEbean,
cache,
javaWs
)
libraryDependencies += "org.postgresql" % "postgresql" % "9.3-1100-jdbc4"
Heroku 的日志:
←[36m2015-05-20T13:35:43.429517+00:00 app[web.1]:←[0m @6m7pfofpb: Database 'default' is in an inconsistent state! ←[36m2015-05-20T13:35:43.412967+00:00 app[web.1]:←[0m [←[31merror←[0m] play - ERROR: type "double" does not exist ←[36m2015-05-20T13:35:43.412974+00:00 app[web.1]:←[0m Position: 320 [ERROR:0, SQLSTATE:42704] ←[36m2015-05-20T13:35:43.428889+00:00 app[web.1]:←[0m Oops, cannot start the server. ←[36m2015-05-20T13:35:43.429771+00:00 app[web.1]:←[0m at play.api.db.evolutions.Evolutions$.checkEvolutionsState(Evolutions.scala:196) ←[36m2015-05-20T13:35:43.429822+00:00 app[web.1]:←[0m at play.api.db.evolutions.Evolutions$.databaseEvolutions(Evolutions.scala:367) ←[36m2015-05-20T13:35:43.429871+00:00 app[web.1]:←[0m at play.api.db.evolutions.Evolutions$$anonfun$evolutionScript.apply(Evolutions.scala:332) ←[36m2015-05-20T13:35:43.429907+00:00 app[web.1]:←[0m at play.api.db.evolutions.Evolutions$$anonfun$evolutionScript.apply(Evolutions.scala:330) ←[36m2015-05-20T13:35:43.433005+00:00 app[web.1]:←[0m at scala.Option.map(Option.scala:145) ←[36m2015-05-20T13:35:43.433063+00:00 app[web.1]:←[0m at play.api.db.evolutions.Evolutions$.evolutionScript(Evolutions.scala:330) ←[36m2015-05-20T13:35:43.433140+00:00 app[web.1]:←[0m at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$$anonfun$apply.apply$mcV$sp(Evolutions.scala:486) ←[36m2015-05-20T13:35:43.433214+00:00 app[web.1]:←[0m at play.api.db.evolutions.EvolutionsPlugin.withLock(Evolutions.scala:531) ←[36m2015-05-20T13:35:43.433254+00:00 app[web.1]:←[0m at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart.apply(Evolutions.scala:485) ←[36m2015-05-20T13:35:43.433294+00:00 app[web.1]:←[0m at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart.apply(Evolutions.scala:483) ←[36m2015-05-20T13:35:43.433333+00:00 app[web.1]:←[0m at scala.collection.immutable.List.foreach(List.scala:383) ←[36m2015-05-20T13:35:43.433450+00:00 app[web.1]:←[0m at play.api.db.evolutions.EvolutionsPlugin.onStart(Evolutions.scala:483) ←[36m2015-05-20T13:35:43.433528+00:00 app[web.1]:←[0m at play.api.Play$$anonfun$start$$anonfun$apply$mcV$sp.apply(Play.scala:91) ←[36m2015-05-20T13:35:43.433588+00:00 app[web.1]:←[0m at play.api.Play$$anonfun$start$$anonfun$apply$mcV$sp.apply(Play.scala:91) ←[36m2015-05-20T13:35:43.433638+00:00 app[web.1]:←[0m at scala.collection.immutable.List.foreach(List.scala:383) ←[36m2015-05-20T13:35:43.433676+00:00 app[web.1]:←[0m at play.api.Play$$anonfun$start.apply$mcV$sp(Play.scala:91) ←[36m2015-05-20T13:35:43.433728+00:00 app[web.1]:←[0m at play.api.Play$$anonfun$start.apply(Play.scala:91) ←[36m2015-05-20T13:35:43.433774+00:00 app[web.1]:←[0m at play.api.Play$$anonfun$start.apply(Play.scala:91) ←[36m2015-05-20T13:35:43.433809+00:00 app[web.1]:←[0m at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ←[36m2015-05-20T13:35:43.433864+00:00 app[web.1]:←[0m at play.api.Play$.start(Play.scala:90) ←[36m2015-05-20T13:35:43.433912+00:00 app[web.1]:←[0m at play.core.StaticApplication.(ApplicationProvider.scala:55) ←[36m2015-05-20T13:35:43.434109+00:00 app[web.1]:←[0m at play.core.server.NettyServer$.createServer(NettyServer.scala:244) ←[36m2015-05-20T13:35:43.434194+00:00 app[web.1]:←[0m at play.core.server.NettyServer$$anonfun$main.apply(NettyServer.scala:280) ←[36m2015-05-20T13:35:43.434302+00:00 app[web.1]:←[0m at play.core.server.NettyServer$$anonfun$main.apply(NettyServer.scala:275) ←[36m2015-05-20T13:35:43.434388+00:00 app[web.1]:←[0m at scala.Option.map(Option.scala:145) ←[36m2015-05-20T13:35:43.434467+00:00 app[web.1]:←[0m at play.core.server.NettyServer$.main(NettyServer.scala:275) ←[36m2015-05-20T13:35:43.434565+00:00 app[web.1]:←[0m at play.core.server.NettyServer.main(NettyServer.scala) ←[36m2015-05-20T13:35:44.389152+00:00 heroku[web.1]:←[0m State changed from starting to crashed ←[36m2015-05-20T13:35:44.376937+00:00 heroku[web.1]:←[0m Process exited with status 255
我特别看不懂这行日志
00:00 app[web.1]:←[0m [←[31merror←[0m] play - ERROR: type "double" does not exist
当然,我的一些项目有一些双重属性class。为什么double类型会出错?
任何 advice/ideas 欢迎 :)
编辑 1
这是我使用 double
类型的仅有的两个 classes。
汽车
@Entity
public class Car extends Model{
@Id
@GeneratedValue
private int id;
@ManyToOne
@JoinColumn(name="user_fk")
private User user;
private String brand;
private String model;
@Column(unique = true)
private String licencePlate;
private String fuel;
private int nbSits;
@Column(name = "avg_cons", columnDefinition = "REAL")
private double avgCons; // Average consumption
@Column(name = "co2_cons", columnDefinition = "REAL")
private double co2Cons;
@Column(name = "htva_price", columnDefinition = "REAL")
private double htvaPrice;
@Column(name = "leasing_price", columnDefinition = "REAL")
private double leasingPrice;
@Column(columnDefinition = "REAL")
private double mileage;
@Column(columnDefinition = "REAL")
private boolean availability;
}
交易
@Entity
@Table(name = "transactions")
public class Transaction extends Model{
@Id
@GeneratedValue
private int id;
@OneToOne
@JoinColumn(name = "car_fk")
private Car car;
@OneToOne
@JoinColumn(name = "driver")
private User driver;
@Column(name = "from_date")
private Timestamp fromDate;
@Column(name = "to_date")
private Timestamp toDate;
@Column(name = "start_mileage", columnDefinition = "REAL")
private double startMileage;
@Column(name = "end_mileage", columnDefinition = "REAL")
private double endMileage;
@Column(columnDefinition = "REAL")
private double avgCons;
private String status;
private boolean exchange;
}
PostgreSQL 使用列类型 double precision 并且不知道列类型 double
我建议尝试
@Column(columnDefinition = "NUMERIC")
private BigDecimal startMileage;
columnDefinition
的值实际上是 DDL 语句的一部分,这就是为什么您应该检查 1.sql 以查看究竟生成了什么(由 Ebean)