【发布时间】:2019-10-19 19:35:42
【问题描述】:
我在一个包uniroma3.siw.model 中创建了一些类,主要在另一个包uniroma3.siw.progetto 中。项目编译并且不会产生任何错误,但在 MySQL Workbench 中没有创建表。
这是我创建的实体之一:
@Entity
public class Admin {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
@Column(nullable=false)
private String nome;
}
我没改主,这是application.proprieties:
spring.jpa.hibernate.ddl-auto=create
spring.datasource.url=jdbc:mysql://localhost:3306/progetto?
serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=****
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
【问题讨论】:
-
小注:术语 WorkBench 是一个工具,而不是一个数据库。表存在于数据库中,MySQL 是本题中的 DBMS
-
尝试更改为
spring.jpa.hibernate.ddl-auto=create-drop或spring.jpa.hibernate.ddl-auto=update。让我们告诉我之后的结果。 -
按照 Spring Boot 团队的最佳实践建议,将 main 移动到
uniroma3.siw。
标签: java mysql spring-boot jpa mysql-workbench