我正在使用spring.io/spring-roo/#running-from-shell快速指南的脚本,一个10行示例。
唯一的修改是jpa setup --provider
行,更改为连接PostgreSQL(HIBERNATE --database POSTGRES
)。所有步骤和代码均位于this roo_hello2pg.md
github document。
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc\:postgresql\://localhost\:5432/hello2bd
spring.datasource.username=postgres
spring.datasource.password=postgres
我还需要什么?一些spring.jpa.hibernate
行?浏览器生成错误" status = 500"使用数据库时(插入一个值)。
答案 0 :(得分:3)
正如我在gitHub存储库中看到的那样,您已正确配置了与Postgres数据库的连接。
但您是否在系统中创建了hello2db
数据库和Timer
表?
作为Spring Boot文档,如果您使用嵌入式数据库(H2,HSQL或Derby),JPA数据库将自动创建
在您的情况下,要使用Postgres DB自动创建数据库,您应该在spring.jpa.hibernate.ddl-auto=create-drop
文件中包含application.properties
属性。
希望它有所帮助,