[英]Tables not created, Using Entities from maven jar dependency in multiple applications in Spring Boot
Having Two Projects有两个项目
my-app我的应用程序
my-entities我的实体
I have my entities in my-entities and i uploading this repository to bitbucket fro hosting then using same repository in my "my-app" project which is a spring boot application and containing database configs like username, dbname, password and i am using spring data jpa with我在 my-entities 中有我的实体,我将此存储库上传到 bitbucket 进行托管,然后在我的“my-app”项目中使用相同的存储库,该项目是一个 Spring Boot 应用程序,包含用户名、dbname、密码等数据库配置,我正在使用 spring数据 jpa 与
spring.jpa.hibernate.ddl-auto=update
Sample Entity class present in my-enties我的实体中存在的示例实体类
@Entity
public class OrganisationDetails {
@Id
@GeneratedValue
private Long id;
private String name;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "OrganisationDetails{" +
"id=" + id +
", name='" + name + '\'' +
'}';
}
}
But tables are not created automatically.但是表不是自动创建的。
spring.jpa.hibernate.ddl-auto=update
- is used to update the current schema spring.jpa.hibernate.ddl-auto=update
- 用于更新当前模式
spring.jpa.hibernate.ddl-auto=create
- is used to create new schema spring.jpa.hibernate.ddl-auto=create
- 用于创建新模式
Normally in development phases the combination - create-drop
is used通常在开发阶段使用组合 - create-drop
spring.jpa.hibernate.ddl-auto=create-drop
You can read more on how to initialize database with spring-boot and JPA here .您可以在此处阅读有关如何使用 spring-boot 和 JPA 初始化数据库的更多信息。
Another vital thing is to specify your SQL dialect.另一个重要的事情是指定您的 SQL 方言。 For example for MySql5例如对于 MySql5
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.