我正在尝试使用 MySQL 数据库启动 spring boot 项目,但是数据库有一些问题。我尝试启动我的应用程序,并且服务器正在运行但休眠不创建表等。这是我的代码:用户实体 @Entity public class User { @Id @GeneratedValue(strategy = IDENTITY) private Long id; private String firstName; private String lastName; private String email; private String password; private String description; private String profile_photo; private LocalDate create; private LocalDate update; @OneToMany(mappedBy = "eventOwner") private List<Event> ownedEvents; public Long getId() { return id;}public void setId(Long id) { this.id = id;}public String getFirstName() { return firstName;}public void setFirstName(String firstName) { this.firstName = firstName;}public String getLastName() { return lastName;}public void setLastName(String lastName) { this.lastName = lastName;}public String getEmail() { return email;}public void setEmail(String email) { this.email = email;}public String getPassword() { return password;}public void setPassword(String password) { this.password = password;}public String getDescription() { return description;}public void setDescription(String description) { this.description = description;}public String getProfile_photo() { return profile_photo;}public void setProfile_photo(String profile_photo) { this.profile_photo = profile_photo;}public LocalDate getCreate() { return create;}public void setCreate(LocalDate create) { this.create = create;}public LocalDate getUpdate() { return update;}public void setUpdate(LocalDate update) { this.update = update;}public List<Event> getOwnedEvents() { return ownedEvents;}public void setOwnedEvents(List<Event> ownedEvents) { this.ownedEvents = ownedEvents;}}
3 回答
斯蒂芬大帝
TA贡献1827条经验 获得超8个赞
将 spring.jpa.hibernate.ddl-auto = create-drop更改为update。它在启动时删除数据库,因此不会找到所需的事件表来更改任何内容。
天涯尽头无女友
TA贡献1831条经验 获得超9个赞
在我的情况下,我得到这个异常的问题是,一些表的名称是为 postgreSQL 保留的。例如。“喜欢”或“用户”。改名为:
@Table(name="likes")
它工作得很好。也许有人有同样的问题。
紫衣仙女
TA贡献1839条经验 获得超15个赞
这似乎是与保留的PostgreSQL 字有关的错误。与最佳答案(SupaMario's)类似,在将我的一个列名从
@Column(name = "name", nullable = false)
至
@Column(name = "employee_name", nullable = false)
添加回答
举报
0/150
提交
取消