gpt4 book ai didi

spring - 组织.postgresql.util.PSQLException : ERROR: relation "dish" does not exist

转载 作者:行者123 更新时间:2023-11-29 14:38:11 24 4
gpt4 key购买 nike

我在 heroku 上创建了 java(spring) 应用程序,将 postgresql 连接到它。当我在应用程序上发出请求时,日志显示

WARN 4 --- [io-14883-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 42P01 app[web.1]: 2016-12-11 12:13:09.942 ERROR 4 --- [io-14883-exec-3] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: relation "dish" does not exist app[web.1]: Position: 13 app[web.1]: 2016-12-11 12:13:10.031 ERROR 4 --- [io-14883-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement] with root cause app[web.1]: org.postgresql.util.PSQLException: ERROR: relation "dish" does not exist app[web.1]: Position: 13

应用程序属性:

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;
}
}

最佳答案

#spring.jpa.hibernate.ddl-auto=create

被注释掉了。所以 Hibernate 不会创建你的表。这就是它们不存在的原因。

关于spring - 组织.postgresql.util.PSQLException : ERROR: relation "dish" does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41086154/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com