메모 수정 API를 작성하던 중
@PutMapping("/{id}")
public ResponseEntity<ScheduleResponseDto> updateSchedule(
@PathVariable Long id,
@RequestBody ScheduleRequestDto requestDto
){
return new ResponseEntity<>(scheduleService.updateSchedule( id,
requestDto.getTitle(),
requestDto.getContents(),
requestDto.getName()), HttpStatus.OK);
}
reason: inference variable T has incompatible bounds
equality constraints: ScheduleResponseDto
lower bounds: ResponseEntity<ScheduleResponseDto>
where T is a type-variable:
T extends Object declared in class ResponseEntity 에러가 발생하였다.
public ResponseEntity<ScheduleResponseDto> updateSchedule(
Long id,
String title,
String contents,
String name
){
Schedule schedule = scheduleRepository.getSchedule(id);
if(schedule == null) {
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
if(title == null || contents == null || name == null){
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
schedule.update(title, contents, name);
return new ResponseEntity<>(new ScheduleResponseDto(schedule), HttpStatus.OK);
}
updateSchedule 메서드가 이미 ResponseEntity<ScheduleResponseDto>를 반환하도록 작성되어 있기 때문에 발생한 오류였다.
return scheduleService.updateSchedule( id,
requestDto.getTitle(),
requestDto.getContents(),
requestDto.getName());
컨트롤러에서 ResponseEntity를 다시 감싸지 않고 반환하여 해결해주었다.
'내배캠' 카테고리의 다른 글
| 팀 프로젝트 트러블슈팅 - 뉴스피드 프로젝트 (0) | 2024.11.21 |
|---|---|
| 개인과제 트러블슈팅 - 일정 관리 앱 Develop (0) | 2024.11.15 |
| 개인과제 트러블슈팅 - 숫자 야구 게임 (0) | 2024.10.25 |
| 개인과제 트러블슈팅 - 계산기 (0) | 2024.10.17 |
| 팀 프로젝트 KTP 개인 회고 (0) | 2024.10.07 |