공통점: 둘 다 URL을 메서드에 연결하는 어노테이션
" HTTP 요청 -> Controller 메서드 "
@RequestMapping("/api/user")
특징 :
단점 :
@GetMapping("/abc")
@PostMapping("/login")
@PutMapping("/{id}")
@DeleteMapping("/{id}")
특징 :
@GetMapping("/abc")
⬇️ 이거랑 같음
@RequestMapping(
value = "/abc",
method = RequestMethod.GET
)
1. 애플리케이션 시작
spring.jpa.hibernate.ddl-auto=update
2. @Entity 스캔
@Entity
public class User {
@Id @GeneratedValue
private Long id;
private String email;
}
--> Hibernate :
“User → 테이블 후보”
3. 테이블 생성 SQL 자동 생성
create table user (
id bigint not null,
email varchar(255),
primary key (id)
);
--> DB에 실행
자바 클래스 ↔ DB 테이블
필드 ↔ 컬럼
(자동 변환이 가능함)
@RestController → 요청 받음 @Service → 로직 처리 @Repository → DB 접근 @Entity → DB 구조