728x90
@PostMapping({ "", "/" })
public String index(@RequestBody String categoryName,
UserDto user, Model model) {
user.getUserId();
LeftService.setCategoryName(user.getUserId(), categoryName);
List<Category> getCategoryList = LeftService.getCategoryList(user, categoryName);
model.addAttribute("getCategoryList", getCategoryList);
return "root.mid_contentList";
}

Cannot make a static reference to the non-static method ~라는 오류가 발생했다.
아직 정확하게 어떤 static값 때문인지는 이해가 안가지만
(32행, 33행을 일단 따로 분리하면 static으로 만들라는 오류가 뜨진 않는다)
@Service
Interface에 메소드를 static으로 만들어줘야 할 듯 하다.
static으로 메서드를 만드니 추상메서드로 만들어지지 않았는데
찾아보니 아래와 같았다.
[ 정리 ]
- interface의 default 메소드
- interface에서도 메소드 구현이 가능하다.
- 참조 변수로 함수를 호출할 수 있다.
- implements한 클래스에서 재정의가 가능하다.
- interface의 static 메소드
- interface에서 메소드 구현이 가능하다.
- 반드시 클래스 명으로 메소드를 호출해야 한다.
- 재정의 불가능!
출처: https://dahyeee.tistory.com/entry/JAVA-interface-default-static메소드 []
728x90
댓글