inblog logo
|
jjack1
    트러블슈팅

    [트러블슈팅] 7. 스프링부트 storev1 list 디버깅

    최재원's avatar
    최재원
    Mar 24, 2025
    [트러블슈팅] 7. 스프링부트 storev1 list 디버깅
    Contents
    1. view1-1. Request로 받아오는 데이터의 key값을 틀린다면(models → model)1-2. mustache 반복문을 사용할 때 key값이 첫 글자만 대문자인 경우 (name → Name)1-3. 없는 key값 사용할 때(id → i)(500)1-4. mustache 반복문 문법을 틀린다면(500)2. controller2-1. / 루트 맵핑을 비워둔다면2-2. / 루트 맵핑이 없다면?(404)2-3. 매핑 메서드를 다르게 한다면(GetMapping → PostMapping)(405)2-4. Request에 데이터를 넘겨주지 않는다면2-5. return하는 파일의 경로를 앞 글자만 대문자로 한다면(store → Store)2-6. return하는 파일이 없다면(list → lists)(400)2-7. return하는 파일이 없다면(2)(/list → /)(404)2-8. 의존성 주입을 받지 못 했다면(500)2-9. 컨테이너 어노테이션을 사용하지 않는다면(404)2-10. 클래스 이름을 Controller라고 한다면3. service3-1. return type을 실수한다면4. repository4-1. 쿼리 메서드 이름 실수4-2. 맵핑 대상을 지정하지 않았을 때4-3. 테이블 이름을 틀렸을 때(500)4-4. 엉뚱한 타입을 import 했을 때
    ❗
    view → controller → service → repository

    1. view

    1-1. Request로 받아오는 데이터의 key값을 틀린다면(models → model)

    notion image
    notion image
    에러는 나타나지 않고 데이터가 표기 되지 않는다

    1-2. mustache 반복문을 사용할 때 key값이 첫 글자만 대문자인 경우 (name → Name)

    notion image
    notion image
    정상 작동한다

    1-3. 없는 key값 사용할 때(id → i)(500)

    notion image
    notion image
    14번째 줄에 'i'라는 이름을 가진 메서드나 필드가 없습니다. com.samskivert.mustache.MustacheException$Context: 14번째 줄에 'i'라는 이름을 가진 메서드나 필드가 없습니다.
    i 값이 없다고 에러가 발생한다

    1-4. mustache 반복문 문법을 틀린다면(500)

    ({{#models}} → {{models}})

    notion image
    notion image
    섹션 닫기 태그에 열린 태그 'models'가 없습니다 @ 18번째 줄 com.samskivert.mustache.MustacheParseException: 섹션 닫기 태그에 열린 태그 'models'가 없습니다 @ 18번째 줄
    #을 사용한 열기 태그가 없다고 나온다

    ({{/models}} → {{models}})

    notion image
    notion image
    섹션에 닫는 태그 'models'가 없습니다 @ 12번째 줄 com.samskivert.mustache.MustacheParseException: 섹션에 닫는 태그 'models'가 없습니다 @ 12번째 줄
    /을 사용한 닫기 태그가 없다고 나온다

    2. controller

    2-1. / 루트 맵핑을 비워둔다면

    notion image
    notion image
    아무 문제가 없다

    2-2. / 루트 맵핑이 없다면?(404)

    notion image
    notion image
    정적 리소스가 없습니다. org.springframework.web.servlet.resource.NoResourceFoundException: 정적 리소스가 없습니다.
    “/” 요청에 대한 파일이 없다고 에러가 발생

    2-3. 매핑 메서드를 다르게 한다면(GetMapping → PostMapping)(405)

    notion image
    notion image
    메서드 'GET'은 지원되지 않습니다. org.springframework.web.HttpRequestMethodNotSupportedException: 요청 메서드 'GET'은 지원되지 않습니다.
    GET 메서드는 지원하지 않는다고 나온다

    2-4. Request에 데이터를 넘겨주지 않는다면

    notion image
    notion image
    그냥 데이터가 보이지 않는다

    2-5. return하는 파일의 경로를 앞 글자만 대문자로 한다면(store → Store)

    notion image
    notion image
    문제 없다

    2-6. return하는 파일이 없다면(list → lists)(400)

    notion image
    notion image
    메서드 매개변수 'id': 'java.lang.String' 유형의 값을 필수 유형 'int'로 변환하는 데 실패했습니다. 입력 문자열의 경우: "lists”

    2-7. return하는 파일이 없다면(2)(/list → /)(404)

    notion image
    notion image
    정적 리소스 저장소가 없습니다. org.springframework.web.servlet.resource.NoResourceFoundException: 정적 리소스 저장소가 없습니다.

    2-8. 의존성 주입을 받지 못 했다면(500)

    notion image
    notion image
    "com.metacoding.storev1.store.StoreService.상품목록()"를 호출할 수 없습니다. "this.storeService"가 null이기 때문입니다. java.lang.NullPointerException: "com.metacoding.storev1.store.StoreService.상품목록()"를 호출할 수 없습니다. "this.storeService"가 null이기 때문입니다.

    2-9. 컨테이너 어노테이션을 사용하지 않는다면(404)

    notion image
    notion image
    정적 리소스가 없습니다. org.springframework.web.servlet.resource.NoResourceFoundException: 정적 리소스가 없습니다.
    리플렉션이 안돼서 리소스를 찾지 못한다

    2-10. 클래스 이름을 Controller라고 한다면

    notion image
    동일한 파일 내에서 Controller라는 이름의 클래스 또는 인터페이스를 정의하고, 동시에 org.springframework.stereotype.Controller를 import하려고 할 때 발생 사용자가 실수로 동일한 이름의 클래스를 생성할때 발생
     

    3. service

    3-1. return type을 실수한다면

    notion image
    notion image
    해결되지 않은 컴파일 문제: StoreService 유형의 상품목록() 메서드가 누락된 유형 저장소를 참조합니다. java.lang.Error: 해결되지 않은 컴파일 문제: StoreService 유형의 상품목록() 메서드가 누락된 유형 저장소를 참조합니다.
    빨간줄이 뜨면서 컴파일 문제가 발생

    4. repository

    4-1. 쿼리 메서드 이름 실수

    notion image
    notion image
    'select * from store_tb order by id desc'라는 이름의 쿼리가 없습니다. org.springframework.dao.InvalidDataAccessApiUsageException: 'select * from store_tb order by id desc'라는 이름의 쿼리가 없습니다.
    해당 쿼리가 없다고 나온다

    4-2. 맵핑 대상을 지정하지 않았을 때

    notion image
    notion image
    14번째 줄에 'id'라는 이름을 가진 메서드나 필드가 없습니다. com.samskivert.mustache.MustacheException$Context: 14번째 줄에 'id'라는 이름을 가진 메서드나 필드가 없습니다.
    머스테치 파일에서 사용하는 id값을 찾지 못한다고 에러가 발생

    4-3. 테이블 이름을 틀렸을 때(500)

    notion image
    notion image
    문장을 준비할 수 없음 [테이블 "BOARD_TB"를 찾을 수 없음; SQL 문장: select * from board_tb order by id desc [42102-232]] [select * from board_tb order by id desc]; SQL [select * from board_tb order by id desc] org.springframework.dao.InvalidDataAccessResourceUsageException: 문장을 준비할 수 없음 [테이블 "BOARD_TB"를 찾을 수 없음; SQL 문장: select * from board_tb order by id desc [42102-232]] [select * from board_tb order by id desc]; SQL [select * from board_tb order by id desc]

    4-4. 엉뚱한 타입을 import 했을 때

    notion image
    notion image
    notion image
    해결되지 않은 컴파일 문제: 유형 불일치: jakarta.persistence.Query에서 org.springframework.data.jpa.repository.Query로 변환할 수 없습니다. getResultList() 메서드는 Query 유형에 대해 정의되지 않았습니다. java.lang.Error: 해결되지 않은 컴파일 문제: 유형 불일치: jakarta.persistence.Query에서 org.springframework.data.jpa.repository.Query로 변환할 수 없습니다. getResultList() 메서드는 Query 유형에 대해 정의되지 않았습니다.
    빨간줄이 뜨고 해당 메서드가 없다고 나온다
     
    Share article
    Contents
    1. view1-1. Request로 받아오는 데이터의 key값을 틀린다면(models → model)1-2. mustache 반복문을 사용할 때 key값이 첫 글자만 대문자인 경우 (name → Name)1-3. 없는 key값 사용할 때(id → i)(500)1-4. mustache 반복문 문법을 틀린다면(500)2. controller2-1. / 루트 맵핑을 비워둔다면2-2. / 루트 맵핑이 없다면?(404)2-3. 매핑 메서드를 다르게 한다면(GetMapping → PostMapping)(405)2-4. Request에 데이터를 넘겨주지 않는다면2-5. return하는 파일의 경로를 앞 글자만 대문자로 한다면(store → Store)2-6. return하는 파일이 없다면(list → lists)(400)2-7. return하는 파일이 없다면(2)(/list → /)(404)2-8. 의존성 주입을 받지 못 했다면(500)2-9. 컨테이너 어노테이션을 사용하지 않는다면(404)2-10. 클래스 이름을 Controller라고 한다면3. service3-1. return type을 실수한다면4. repository4-1. 쿼리 메서드 이름 실수4-2. 맵핑 대상을 지정하지 않았을 때4-3. 테이블 이름을 틀렸을 때(500)4-4. 엉뚱한 타입을 import 했을 때

    jjack1

    RSS·Powered by Inblog