Java Rest api响应数据未使用Spring JPA保存在数据库中

Java Rest api响应数据未使用Spring JPA保存在数据库中,java,database,rest,spring-data-jpa,Java,Database,Rest,Spring Data Jpa,我对Spring相关的东西都是新手,所以你能帮我解决这个问题吗?我正在尝试编写一个注册api,使用SpringJPA在数据库中保存一些数据 这是我的密码: @实体模型: @Entity @Table(name = "registerapplications") public class RegisterApplication { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id

我对Spring相关的东西都是新手,所以你能帮我解决这个问题吗?我正在尝试编写一个注册api,使用SpringJPA在数据库中保存一些数据

这是我的密码:

@实体模型:

@Entity
@Table(name = "registerapplications")
public class RegisterApplication {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id; 

    private String applicationId;

    public RegisterApplication (String applicationId) {
        this.applicationId = applicationId;
    }

    // Getters and Setter
}
存储库:

public interface RegisterRepository extends CrudRepository<RegisterApplication, Long>{

}
application.properties:

spring.jpa.hibernate.ddl-auto=create
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/register
spring.datasource.username=admin
spring.datasource.password=admin
请求工作正常,但未将数据保存在我的表中:


我没有出错,所以我不知道问题出在哪里。你能看一下代码并给我一些提示吗?

我想你出现问题的原因是你忘记了用
@Column
在你的
实体中的
应用程序ID
字段上加上

的注释,反应是什么?您向
/register
发送了什么?我没有请求正文。这是响应:{“id”:1,“applicationId”:“fc1d499e-133c-42de-912d-082957d0baca”},我想在registerapplications的数据库中添加id和applicationIdtable@deedee88您是否手动创建了db表?因为它的列数多于实体中定义的列数。也许删除该表,让JPA创建itI我只尝试了这两列,我也尝试了让JPA创建表,但它不创建ITA有sql日志吗?将
spring.jpa.show sql=true
添加到您的
应用程序.properties
以启用sql日志在多次更改后,我设法解决了这个问题。我认为主要的问题是资源包在java包下,而不是主包。从那以后,我一个接一个地犯错,直到成功。谢谢你的帮助,瓦伦丁。
spring.jpa.hibernate.ddl-auto=create
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/register
spring.datasource.username=admin
spring.datasource.password=admin