[英]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.