我收到“ accepted_at”列标题中的错误,但是我看不到我在哪里出错,因为我检查了列的名称,并且实体似乎被正确注释了。使用了Lombok,所以不知道为什么没有二传手和吸气剂

@Id
@GeneratedValue
private Long id;
private Long version;

@Column(name = "accepted_at")
private Date acceptedAt;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "accepted_by_id")
private Account acceptedBy;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "account_id")
private Account account;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "token_id")
private Token token;

@Column(name = "date_created")
private Date dateCreated;

@Column(name = "is_accepted")
private Boolean isAccepted;

@Column(name = "is_enabled")
private Boolean isEnabled;

@Column(name = "last_updated")
private Date lastUpdated;

@Column(name = "organization_id")
private String organizationId;

@Column(name = "pending_status")
private int pendingStatus;

@Column(name = "pending_status_date")
private Date pendingStatusDate;

@Column(name = "profile_type")
private int profileType;

@Column(name = "valid_from")
private Date validFrom;

@Column(name = "valid_to")
private Date validTo;


这是我通过脚本为配置文件创建表的方式。

create table profile
(
id                   bigint(20) not null auto_increment,
version              bigint(20) not null,
accepted_at          datetime,
accepted_by_id       bigint(20),
account_id           bigint(20) not null,
token_id             bigint(20),
date_created         datetime,
is_accepted          bit(1) not null,
is_enabled           bit(1) not null,
last_updated         datetime,
organization_id      national varchar(10) not null,
pending_status       int(11),
pending_status_date  datetime,
profile_type         int(11) not null,
valid_from           datetime,
valid_to             datetime,
primary key (id),
key organization_id (organization_id)
);


我正在使用application.yml而不是application.properites。我希望这是有用的

 spring:
  datasource:
   url: jdbc:mysql://localhost/*****?serverTimezone=GMT
   username: root
   password: ******
  jpa:
   open-in-view: false
 flyway:
  enabled: true
 thymeleaf:
  suffix: .html
  cache: false

最佳答案

请使用以下内容替换您的yml属性:

spring:
  datasource:
   url: jdbc:mysql://localhost/focus3?serverTimezone=GMT
   username: root
   password: 123456
  jpa:
   open-in-view: false
    hibernate:
    naming:
      physical-strategy : org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
 flyway:
  enabled: true
 thymeleaf:
  suffix: .html
  cache: false


因为,您的yml属性应在下面使用您的字段名称,

spring:
  jpa:
    hibernate:
      naming:
        physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

10-06 12:09