728x90

문제

Error attempting to get column 'id' from result set

이런 오류가 발생했다. 너무 어처구니 없는 오류였다.

 

해결

BEFORE

<select id="loginCheck" resultType="boolean" parameterType="String">
    SELECT
        id AS id,
        email AS email,
        name AS name,
        nick_name AS nickName,
        phone AS phone,
        forgot_pw_question AS forgotPwQuestion,
        forgot_pw_answer AS forgotPwAnswer
    FROM t_identity
    WHERE email = #{email}
</select>

 

AFTER

<select id="loginCheck" resultType="HashMap" parameterType="String">
    SELECT
        id AS id,
        email AS email,
        name AS name,
        nick_name AS nickName,
        phone AS phone,
        forgot_pw_question AS forgotPwQuestion,
        forgot_pw_answer AS forgotPwAnswer
    FROM t_identity
    WHERE email = #{email}
</select>

 

느낀 점

생각 짧았다.. mybatis를 처음 하다보니까 인터페이스에 선언하는 것과 메소드에 선언하는 것을 잠깐 혼동하고 저 sql 문에 해당하는 값이 db에 있으면 true 없으면 false로 출력한다는 생각에만 사로잡혀서 resultType 을 boolean 으로 해놓았다. 그래서 이런 에러가 생겼던 것이었다. HashMap 으로 바꾸니 정상적으로 됐다.

728x90

문제

mybatis에서 실제 sql이 있는 xml 파일이 인터페이스로 된 파일(DAO) 에서 Param 으로 들어오는 값들을 @Param("")으로 지정을 해주지 않아서 인식을 못해 바인딩이 되지 않은 것 같다.

 

해결

BEFORE

Boolean loginCheck(String email);

 

AFTER

Boolean loginCheck(@Param("email")String email);

 

느낀 점

지금까지 전 처럼 사용했는데 이런 오류가 난거 보니까 잘못 써 온것같다.

728x90

문제

attempted to return null from a method with a primitive return type (boolean)

방금 개발을 하다가 이처럼 에러가 났다. 내가 반환하려고 하는 타입은 boolean 인데 null 로 반환되었기 때문에 이러한 에러가 발생했다.

 

해결

null 값도 받을 수 있는 Wrapper Class 를 사용하면 된다.

그래서 return type인 boolean 을 Boolean 으로 바꿔주었다. 정상적으로 동작한다.

 

느낀 점

자바의 기초를 다져놓고 스프링을 하니까 뭔가 많이 편하고 더 알아가는 것과 느끼는 것이 많아서 좋다 ㅎㅎ

다시 한번 기초가 중요하다는 것을 느꼈다!

728x90
바뀌기 전

 

원래 쿼리 매핑을 해주는 xml 파일인 "DoseoroDao.xml" 이 원래 dao 폴더에 있었고 application.yml 에는 밑에와 같이 있었다.

mybatis:
  config-location: classpath:mapper.xml

 

바뀐 후

 

 

Deoseoro.xml 파일을 resources 폴더로 옮기고 밑에와 같이 추가 하니까 정상적으로 실행 되었다..

mybatis:
  config-location: classpath:mapper.xml
  mapper-locations: classpath:DoseoroDao.xml

 

느낀 점

폴더 경로를 인식하는데 문제가 있는 것 같았다. 리소스 루트소스 루트의 경로 인식이 다른 것 같다. 이를 명심해야겠다..

 

 

참조

https://twofootdog.github.io/Mybatis-Invalid-bound-statement(not-found)-%EC%97%90%EB%9F%AC/ 

 

[Mybatis]invalid bound statement (not found) 에러 | 두발로걷는개

Mybatis 에러 원인 및 해결 방법

twofootdog.github.io

 

728x90

jsp 를 처음 경험해본다.

노드 js 로 되어 있었고 템플릿은 Html 이랑 비슷한 넌적스로 되어 있던 것을 jsp 로 바꾸는 과정에서 한글이 깨지는 현상을 만났다. 

이렇게 말이다..

 

해결

 

.jsp 파일 상단에

<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

이 코드를 추가하니까 해결이 되었다.

728x90

몇일 코딩을 쉬면서 이론 공부를 하다가 일주일 뒤에 프로젝트를 열어서 코딩을 하려고 하니 이런 에러가 났다. 해결법은 다음과 같다.

 

나는 Gradle을 사용하고 있기 때문에, build.gradle 파일에 dependencies 항목을 다음과 같이 바꿔주었다.

implementation 'org.springframework.boot:spring-boot-starter-web'

 

 

참고

https://github.com/etture/dev_notes/issues/15

 

Spring Boot: error “package org.springframework.web.bind.annotation does not exist” · Issue #15 · etture/dev_notes

in build.gradle, change org.springframework.boot:spring-boot-starter to org.springframework.boot:spring-boot-starter-web

github.com

 

728x90
오류 내용

오류 해결
  •  npm i ~ 뒤에 ' --save --legacy-peer-deps '를 추가를 하면 된다. 

+ Recent posts