You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
🔍 애노테이션의 시작부터 현재
1. 애노테이션의 시작 (JDK 5, 2004년)
👉 그래서 **JDK 5 (2004년)**에서 애노테이션을 도입하면서 코드 안에서 직접 설정할 수 있도록 개선
2. 애노테이션의 확장 (Spring, JPA, Lombok)
@JsonSubTypes등과 결합 가능📌 예시
@Override→ 부모 클래스의 메서드를 제대로 오버라이딩했는지 검사@Deprecated→ 더 이상 사용하지 않는 메서드(나중에 삭제될 예정)@SuppressWarnings("deprecation")→@Deprecated경고를 무시Spring 애노테이션(DI, MVC, 트랜잭션)
→ @component, @service, @repository, @Autowired
@Component→ Spring Bean 등록 (기본적인 컴포넌트로 사용)@Service→ 비즈니스 로직을 담당하는 클래스@Repository→ DB 관련 작업을 처리하는 클래스@Autowired→ Spring이 자동으로 객체를 주입해줌Spring MVC 애노테이션(Controller, API 요청 처리)
→ @RestController, @RequestMapping, @GetMapping, @PostMapping
@RestController→ Spring MVC 컨트롤러, JSON 응답을 반환@RequestMapping("/api")→ 공통 URL을 지정하여 그룹화@GetMapping("/hello")→ GET 요청을 처리@PostMapping("/add")→ POST 요청을 처리하고 데이터를 받음Spring 트랜잭션 관리
->@transactional
@Transactional→ 트랜잭션을 관리하여 오류 발생 시 롤백 처리JPA 애노테이션(ORM, DB 매핑)
→ @entity, @id, @column, @GeneratedValue
@Entity→ 클래스를 DB 테이블과 매핑@Table(name = "users")→ 테이블 이름 설정 (생략 가능)@Id→ 기본 키(PK) 설정@GeneratedValue(strategy = GenerationType.IDENTITY)→ 자동 증가 (MySQL 사용)@Column(name = "user_name", nullable = false)→ DB 컬럼 이름과 제약 조건 설정Lombok 애노테이션
→ @Getter, @Setter, @DaTa, @AllArgsConstructor, @NoArgsConstructor
@Data→@Getter,@Setter,@ToString,@EqualsAndHashCode자동 적용@AllArgsConstructor→ 모든 필드를 받는 생성자 자동 생성@NoArgsConstructor→ 기본 생성자 자동 생성All reactions