【发布时间】:2017-04-26 10:49:53
【问题描述】:
我在 heroku 上创建了 java(spring) 应用程序,并将 postgresql 连接到它。当我在应用程序上发出请求时,日志显示
警告 4 --- [io-14883-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper:SQL 错误:0,SQLState:42P01 应用 [web.1]:2016-12-11 12:13:09.942 错误 4 --- [io-14883-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper:错误:关系“菜”不存在 应用[web.1]:位置:13 应用程序 [web.1]:2016-12-11 12:13:10.031 错误 4 --- [io-14883-exec-3] oaccC[.[.[/].[dispatcherServlet]:Servlet.service() 用于带有路径 [] 的上下文中的 servlet [dispatcherServlet] 引发异常 [请求处理失败;嵌套异常是 org.springframework.dao.InvalidDataAccessResourceUsageException:无法执行语句; SQL [不适用];嵌套异常是 org.hibernate.exception.SQLGrammarException: could not execute statement] 根本原因 app[web.1]: org.postgresql.util.PSQLException: 错误:关系“dish”不存在 app[web.1]:位置:13
application.properties:
spring.datasource.url=${JDBC_DATABASE_URL}
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.maxActive=10
spring.datasource.maxIdle=5
spring.datasource.minIdle=2
spring.datasource.initialSize=5
spring.datasource.removeAbandoned=true
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.generate-ddl=false
#spring.jpa.hibernate.ddl-auto=create
spring.jpa.show-sql=true
这个模型在我的本地机器上工作
型号:
@Entity
public class Dish
implements Serializable
{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private Long dishId;
private Long categoryId;
private String name;
private String description;
private Float price;
private String picUrl;
public Long getId()
{
return this.dishId;
}
public void setId(Long dishId)
{
this.dishId = dishId;
}
public Long getCategoryId()
{
return this.categoryId;
}
public void setCategoryId(Long categoryId)
{
this.categoryId = categoryId;
}
public String getName()
{
return this.name;
}
public void setName(String name)
{
this.name = name;
}
public String getDescription()
{
return this.description;
}
public void setDescription(String description)
{
this.description = description;
}
public Float getPrice()
{
return this.price;
}
public void setPrice(Float price)
{
this.price = price;
}
public String getPicUrl()
{
return this.picUrl;
}
public void setPicUrl(String picUrl)
{
this.picUrl = picUrl;
}
}
【问题讨论】:
-
所以没有名为dish 的表。问题出在哪里?
-
@CraigRinger MR CAP)) 我知道,我的问题是为什么?我在本地机器上做了实体,但在 heroku 上却没有
标签: spring postgresql hibernate heroku heroku-postgres