관리 메뉴

gi_dor

[error] org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) λ³Έλ¬Έ

Back_End/Issue

[error] org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

기돌 2024. 4. 15. 09:08

πŸ”’ 였λ₯˜ ν˜„μƒ

νšŒμ›κ°€μž… μ§„ν–‰μ‹œ completed νŽ˜μ΄μ§€λ‘œ μ΄λ™ν•˜μ§€ μ•Šκ³  ν•΄λ‹Ή 였λ₯˜κ°€ λ°œμƒν–ˆλ‹€

 

 

πŸ“Œ μ˜ˆμƒ 해결방법

1. Mapper Interface 와 λ§€ν•‘λ˜λŠ” xml νŒŒμΌμ— μ˜€νƒ€

<!-- id에 곡백이 μžˆλ‹€. -->
<select id="select " resultTYpe="String">
    ...
</select>

 

2. mapper-locations

mybatis.mapper-locations:classpath:mapper/*.xml

 

Mapper μΈν„°νŽ˜μ΄μŠ€

@Mapper
public interface UserMapper {


    void insertUser(User user);

    User selectUserByNo(Long no);

    User selectUserById(String id);

    User selectUserByEmail(String email);

     int idCheck(String id);

     int emailCheck(String email);

}

 

User.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.example.bookhub.user.mapper.UserMapper">

    <resultMap id="UserResultMap" type="com.example.bookhub.user.vo.User">
        <id column="user_no" property="no" />
        <result column="user_id" property="id" />
        <result column="user_password" property="password" />
        <result column="user_name" property="name" />
        <result column="user_email" property="email" />
        <result column="user_created_date" property="createdDate" />
        <result column="user_updated_date" property="updatedDate" />
        <result column="user_tel" property="tel" />
        <result column="user_zip_code" property="zipCode" />
        <result column="user_address" property="address" />
        <result column="user_address_detail" property="addressDetail" />
        <result column="user_del_yn" property="delYn" />
    </resultMap>

     <select id="selectUserById" parameterType="string" resultMap="UserResultMap">
        SELECT user_no ,
               user_id ,
               user_password ,
               user_name ,
               user_email ,
               user_tel ,
               user_zip_code ,
               user_address,
               user_address_detail ,
               user_created_date ,
               user_updated_date
        FROM USER
        WHERE user_id = #{id}
    </select>
    
</mapper>

 

 

 XML νŒŒμΌμ—λŠ” μ˜€νƒ€μ™€ 곡백이 μ—†μ—ˆλ‹€ , 인텔리버전을 μ‚¬μš©ν•΄ μ˜€νƒ€κ°€ μ—†λŠ”μ§€ μ‰½κ²Œ λ°œκ²¬ν•  수 μžˆλ‹€

ꡬ글링 κ²°κ³Ό application.properties νŒŒμΌμ—μ„œ λ¬Έμ œκ°€ 생길 수 μžˆλ‹€κ³ ν•œλ‹€

spring.application.name=BookHub

spring.datasource.url=jdbc:mysql://database-1.crzth3asbpqd.ap-northeast-2.rds.amazonaws.com:3306/BookHub
spring.datasource.username=
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

mybatis.mapper-locations=classpath:/mybatis/mappers/*/*.xml
mybatis.configuration.jdbc-type-for-null=null
mybatis.configuration.log-impl=org.apache.ibatis.logging.log4j2.Log4j2Impl

 

 

 

mybatis.mapper-locations=classpath:/mybatis/mappers/*/*.xml

μ„€μ •ν•œ 경둜 외에 μœ„μΉ˜ν•œ 곳에 xml 파일이 μžˆμ–΄μ„œ 

728x90