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 i...

问题:

Having Two Projects

  1. my-app

  2. 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

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.


回答1:

spring.jpa.hibernate.ddl-auto=update - is used to update the current schema

spring.jpa.hibernate.ddl-auto=create - is used to create new schema

Normally in development phases the combination - create-drop is used

spring.jpa.hibernate.ddl-auto=create-drop

You can read more on how to initialize database with spring-boot and JPA here.

Another vital thing is to specify your SQL dialect. For example for MySql5

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
  • 发表于 2019-03-27 03:51
  • 阅读 ( 218 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除