반응형
SMALL
package com.in28minutes.rest.webservices.restfulwebservices.user;
import java.time.LocalDate;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.validation.constraints.Past;
import jakarta.validation.constraints.Size;
@Entity(name = "user_details") //JPA가 관리하기 위하여 Entity설정
public class User {
@Id //식별자
@GeneratedValue //생성되어야함으로
private Integer Id;
@JsonProperty("users_name")
@Size(min = 2, message = "Name should have atleast 2 ")
private String name;
@JsonProperty("birth_date")
@Past(message = "Birth date should be in the pest")
private LocalDate birthday;
public User(Integer id, String name, LocalDate birthday) {
super();
Id = id;
this.name = name;
this.birthday = birthday;
}
public Integer getId() {
return Id;
}
public void setId(Integer id) {
Id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public LocalDate getBirthday() {
return birthday;
}
public void setBirthday(LocalDate birthday) {
this.birthday = birthday;
}
@Override
public String toString() {
return "User [Id=" + Id + ", name=" + name + ", birthday=" + birthday + "]";
}
}
pom.xml
spring.datasource.url=jdbc:h2:mem:testdb
spring.jpa.defer-datasource-initialization=true
h2 콘솔 정적로그
sql 지연시작
data.sql 추가
insert into user_details(id,birthday,name)
values(10001,current_date(),'Ranga');
insert into user_details(id,birthday,name)
values(10002,current_date(),'Ravi');
insert into user_details(id,birthday,name)
values(10003,current_date(),'JH');
반응형
LIST
'Spring > Spring Boot' 카테고리의 다른 글
Actuator로 API 모니터링/HAL explorer로 API 탐색 (0) | 2023.10.06 |
---|---|
Rest API 동적 필터링 (0) | 2023.10.06 |
REST API 버전 관리 (params, headers, produces) (0) | 2023.10.05 |
name, password 구현 (0) | 2023.09.21 |
logging (0) | 2023.09.21 |