Spring Boot和Hibernate创建架构,但不创建表

时间:2019-03-09 08:03:21

标签: hibernate spring-boot

我正在使用hibernate自动生成数据库架构和表。 生成架构,但不生成表。

如何生成表?

application.properties文件:

#jdbc
spring.jpa.hibernate.ddl-auto=create
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url = jdbc:mysql://127.0.0.1:3306/tutor?createDatabaseIfNotExist=true&useUnicode=yes&characterEncoding=UTF-8
jdbc.user= root
jdbc.password =

# hibernate.X
hibernate.dialect=org.hibernate.dialect.MySQL5DBDialect
hibernate.show_sql=false
hibernate.hbm2ddl.auto=validate
#hibernate.hbm2ddl.auto=create-drop
pool.size=2

Account.java文件:

@Entity
@Table
public class Account implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column
    private Integer id;

    @Column
    private String username;

    @Column
    private String password;

    public Integer getId() {
        return id;
    }

    public String getUsername() {
        return username;
    }

谢谢。

0 个答案:

没有答案