简体   繁体   English

未创建表,在 Spring Boot 中的多个应用程序中使用来自 maven jar 依赖项的实体

[英]Tables not created, Using Entities from maven jar dependency in multiple applications in Spring Boot

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我在 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.

相关问题 使用 spring-boot-maven-plugin 从依赖 jar 拆分版本号? - Spliting version number from dependency jar using spring-boot-maven-plugin? spring-boot-maven-plugin创建的jar通过使用classpath运行 - spring-boot-maven-plugin created jar run by using classpath Spring Boot - 从外部jar映射实体 - Spring Boot - mapping Entities from external jar Spring Boot:无法识别 Maven 依赖项中的实体:“不是托管类型” - Spring Boot: Entities within a Maven dependency not recognized: "Not a managed type" 具有jar依赖项的Spring Boot应用程序在Maven构建后无法运行 - Spring Boot application with a jar dependency does not run after maven build 使用Spring Boot Maven项目作为依赖项 - Using a Spring boot maven project as a dependency 使用 Spring Boot Maven 插件时,jar 文件中缺少 Spring Boot 应用程序中的资源 - resources in a Spring Boot application are missing from jar file when using Spring Boot Maven Plugin 如何为我的Java应用程序+ mysql创建可安装文件(从maven build spring boot创建的jar) - How to create installable for my java application + mysql (jar created from maven build spring boot) 在运行spring boot jar时使用外部jar作为依赖文件 - Using external jar as dependency file while running spring boot jar 如何使用 maven 将 spring-boot 打包到带有本地 jar 的 jar - How to package spring-boot to jar with local jar using maven
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM