【发布时间】:2022-01-31 06:21:40
【问题描述】:
发布此内容是因为我还没有看到有关此问题的 FLOAT 类型的帖子。
No validator could be found for constraint 'javax.validation.constraints.Size' validating type 'java.lang.Float'. Check configuration for 'numIngredient'
如何更改约束以应用 FLOAT 类型?
@Data
@Entity
@Table(name = "pantry")
public class Pantry {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "userID", nullable = false)
private Long userID;
@Column(name = "ingredients_in_pantry", nullable = true)
private String ingredientID;
@NotNull
@Column(name = "number_of_ingredients", nullable = true)
private Float numIngredient;
//description of pantry (home, office, kitchen, grandmas, etc.)
@Column(name = "description", nullable = true)
private String description;
}
【问题讨论】:
标签: java spring-boot floating-point