提问人:Spiros Vatikiotis 提问时间:11/15/2023 最后编辑:Spiros Vatikiotis 更新时间:11/15/2023 访问量:24
无法通过休眠创建表。虽然我的应用程序运行没有错误
Table cannot be created through hibernate. Though my application runs without errors
问:
尝试通过我的应用程序自动创建mysql表。虽然我在运行应用程序时没有出现任何错误。未创建任何表
我的模型类
package user;
import jakarta.persistence.*;
@Entity
@Table(name = "users")
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(nullable = false, unique = true, length = 45)
private String email;
@Column(length = 15, nullable = false)
private String password;
@Column(length = 45, nullable = false, name = "first_name")
private String firstName;
@Column(length = 45, nullable = false, name = "last_name")
private String lastName;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
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 getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
}
我的application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/usersdb
spring.datasource.username=root
spring.datasource.password=********
spring.jpa.hibernate.ddl-auto=update
spring.jpa.generate-ddl=true
spring.jpa.properties.hibernate.show_sql=true
不确定在application.properties文件中是否做错了什么 我想我在 User 类中得到了正确的注释。 我在运行应用程序时没有收到任何错误,但没有创建任何表。
答: 暂无答案
评论