我正在尝试基于实体生成架构表。但是没有创建表。出了什么问题?
实体示例:
@Entity
@NoArgsConstructor
@Getter @Setter
public class User {
@Id @GeneratedValue(strategy = GenerationType.AUTO)
public Long id;
public String username;
public String password;
public User(String username, String password) {
this.username = username;
this.password = password;
}
public User(String username) {
this(username, username + "pass");
}
}
application.properties
:
spring.datasource.url=jdbc:postgresql://localhost:5432/dbtest
spring.datasource.username=vssekorin
spring.datasource.password=
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
spring.jpa.hibernate.ddl-auto=update
依赖关系:
compile('org.springframework.boot:spring-boot-starter-data-jpa')
runtime('com.h2database:h2')
compile('org.telegram:telegrambots:3.6.1')
runtime('org.postgresql:postgresql')
compileOnly('org.projectlombok:lombok')
testCompile('org.springframework.boot:spring-boot-starter-test')
警告:GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement
4条答案
按热度按时间qjp7pelc1#
它应该是:
在你的
application.properties
里。或者您可以更改此行:
在
更多详情:Spring Database initialization
cgyqldqp2#
只需将
spring.jpa.hibernate.ddl-auto
从update
更改为create
。5gfr0r5j3#
尝试添加此属性spring.datasource.driverClassName=org.postgresql.Driver
并将spring.jpa.hibernate.ddl-auto从更新更改为创建
hi3rlvi24#
实体(name=“Users”)postgresql无法创建名为user和