-> 회원 DB에 이름, 나이,성별이 있는 경우
@AllArgsConstructor
: 모든 필드 값을 파라미터로 받는 생성자를 추가public class Person {
private String name;
private int age;
public Person (String name, int age) {
this.name = name;
this.age = age;
}
}
-> 원래는 모든 필드값 받는 생성자를 이렇게 생성해야 함
@AllArgsConstructor
public class Person {
private String name;
private int age;
public Person (String name, int age) {
this.name = name;
this.age = age;
}
}
-> 어노테이션 생성하면 자동으로 생성자 추가해줌
@RequiredArgsConstructor
: final이나 @NonNull인 필드 값만 파라미터로 받는 생성자를 추가@NoArgsConstructor
: 기본 생성자를 자동으로 추가@RestController
: Spring에서 Controller 중 View로 응답하지 않는, Controller를 의미, 반환 결과를 JSON 형태로 반환한다.RestController = @Controller + @ResponseBody
@PostMapping
: @RequestMapping(Method=RequestMethod.POST)과 같다.@Service
: 비즈니스 로직을 수행하는 class라는 것을 의미@SpringBootApplication
: @Configuration, @EnableAutoConfiguration, @ComponentScan 3가지를 하나의 애노테이션으로 합친 것