简体   繁体   English

Spring-Boot 运行时。项目的 JAR 无法初始化 JPA

[英]Spring-Boot When running .JAR of project it fails to initialize JPA

What I want to achieve is that when I push something to my staging branch on github a script on the Ubuntu server automatically pulls the branch, compiles the project and runs the.JAR file.我想要实现的是,当我将某些内容推送到 github 上的暂存分支时,Ubuntu 服务器上的脚本会自动拉取分支,编译项目并运行.Z529E625C8C2BF37C68ZFADAE4 文件。

But I'm facing a problem where if I package my project on Ubuntu it fails to initialize JPA EntityManagerFactory.但是我遇到了一个问题,如果我在 Ubuntu 上进行 package 项目,则它无法初始化 JPA EntityManagerFactory。 It gives the following exception: "Failed to initialize JPA EntityManagerFactory: Unable to find column with logical name category in table hardware"它给出了以下异常:“无法初始化 JPA EntityManagerFactory:无法在表硬件中找到具有逻辑名称类别的列”

Whenever I run the project on Ubuntu with the "mvn spring-boot:run" command it runs fine without any problem.每当我使用“mvn spring-boot:run”命令在 Ubuntu 上运行项目时,它运行良好,没有任何问题。 Also when I compile the project on Windows the.JAR file runs fine too.此外,当我在 Windows 上编译项目时,.JAR 文件也运行良好。 I made sure I use the same versions of the JDK and Maven on Ubuntu and my Windows PC.我确保在 Ubuntu 和我的 Windows PC 上使用相同版本的 JDK 和 Maven。 The dependency versions are also the same.依赖版本也是一样的。 When I run the.JAR file I made on my Windows PC on Ubuntu it runs fine too.当我在 Ubuntu 上的 Windows PC 上运行 .JAR 文件时,它也运行良好。 I have no clue what the issue could be.我不知道问题可能是什么。

HardwareEntity.java HardwareEntity.java

@Entity
@Table(name = "hardware")
public class HardwareEntity {
    @Id
    private String sku;
    @Column(length = 55)
    private String size;
    @Column(length = 55)
    private String type;
    @Column(length = 55)
    private String control;
    private String color;
    private String status;
    private Integer delivery_time;
    @ManyToOne
    @JoinColumn(name = "category")
    private CategoryEntity category;

    // Getters & Setters
} 

CategoryEntity.java类别Entity.java

@Entity
@Table(name = "category")
public class CategoryEntity {
    @Id
    @Column(length = 55)
    private String code;
    private String description;
    @OneToMany(mappedBy = "category")
    private List<SoftwareEntity> families;
    @OneToMany(mappedBy = "category")
    private List<HardwareEntity> hardwares;
    
    // Getters & Setters
}

I fixed it by creating an image of an Ubuntu system where everything did work as expected and then use that image on the server.我通过创建 Ubuntu 系统的映像来修复它,其中一切都按预期工作,然后在服务器上使用该映像。 I still don't know what the exact issue was but it's fixed.我仍然不知道确切的问题是什么,但它已修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行 Jar 时强制启用 spring-boot DevTools - Force enable spring-boot DevTools when running Jar 加载spring-boot和spring-data-jpa时,Hibernate无法加载JPA 2.1 Converter - Hibernate fails to load JPA 2.1 Converter when loaded with spring-boot and spring-data-jpa 将一个 spring-boot 项目作为 jar 添加到另一个项目中 - Add one spring-boot project as a jar to another project 将Spring Web项目打包到没有Spring Boot的jar(uber-jar)中(非spring-boot项目) - Package Spring web project into jar (uber-jar) without spring boot (non spring-boot project) spring-boot jar:仅在通过cron程序运行时,连接超时 - spring-boot jar: connection time out only when running through cron program 循环依赖只在运行 java -jar 时,而不是 spring-boot:run - Cyclic dependency only when running java -jar, not with spring-boot:run 如何在不改变原有pom的情况下,在新的spring-boot项目中添加spring-boot jar作为依赖 - How to add a spring-boot jar as a dependency in a new spring-boot project without changing the original pom 使用 Maven 构建 spring-boot 项目时将文件复制到 jar 根目录 - Copy file to jar root when building spring-boot project with Maven 无法将 JPA 依赖项添加到 spring-boot 项目中 - Not able to add JPA dependency into spring-boot project 从命令行运行分解的 spring-boot jar - Running an exploded spring-boot jar from command line
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM