오류가 이렇게 뜨는데
496
작성한 질문수 24
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="hello.sailing_jsp.v2.dao.MenuDaoV2">
<!--조회-->
<select id="doList" resultType="hello.sailing_jsp.v2.vo.Coffee_menu">
select no,
coffee,
kind,
price,
date_format(reg_day,'%Y,%m,%d') as reg_day,
date_format(mod_day,'%y,%m,%d') as mod_day
from coffee_menu
</select>
<!--검색에 의한 쿼리-->
<select id="doSearch" resultType="hello.sailing_jsp.v2.vo.Coffee_menu">
select no,
coffee,
kind,
price,
date_format(reg_day,'%Y,%m,%d')as reg_day,
date_format(mod_day,'%y,%m,%d')as mod_day
from coffee_menu
where 1=1
and reg_day >= date_format( #{strStartDate}, '%Y,%m,%d')
and reg_day < date_add(date_format(#{strEndDate}, '%Y,%m,%d'), interval +1 day)
<if test="strCoffee != 'ALL'">
and coffee like concat('%',#{strCoffee},'%')
</if>
<if test="strKind != 'ALL'">
and kind = #{strKind}
</if>
</select>
<!--메뉴조회-->
<select id="doListOne" resultType="java.util.Map">
select no,
coffee,
kind,
price,
date_format(reg_day,'%Y,%m,%d')as reg_day,
date_format(mod_day,'%y,%m,%d')as mod_day
from coffee_menu
where no = cast(#{strNo} as Integer)
</select>
<insert id="doInsert">
Insert Into coffee_menu(coffee,kind,price)
values(#{coffee},#{kind},cast(#{price} as Integer))
</insert>
<update id="doUpdate">
update coffee_menu set
coffee = #{coffee},
kind = #{kind},
price = cast(#{price} as Integer)
where no = cast(#{no} as Integer)
</update>
<delete id="doDelete">
Delete from coffee_menu where no = cast(#{strNo} as Integer)
</delete>
<!--메뉴 가격 수정 입력-->
<update id="doUpdatePrice">
update coffee_menu set
price = cast(#{strPrice} as integer)
where no = cast(#{strNo} as integer)
</update>
<!--가격 로그 입력-->
<insert id="doInsertLog">
insert into coffee_menu_log(coffee_no, price)
values( #{strNo}, cast(#{strPrice} as integer) )
</insert>
<!--메뉴 가격 수정 원쿼리로 처리-->
<update id="doUpdatePriceOne">
update coffee_menu set
price = cast(#{strPrice} as integer)
<where>
<foreach item="item" index="index" collection="chkList" open="no in (" separator="," close=")" nullable="true">
#{item}
</foreach>
</where>
</update>
<!--가격 로그 입력 원쿼리-->
<insert id="doInsertLogOne">
insert into coffee_menu_log(coffee_no, price)
<foreach item="item" index="index" collection="chkList" separator="union all" nullable="true">
select #{item}, cast(#{strPrice} as integer) from dual
</foreach>
</insert>
<!--boot 로그 입력-->
<insert id="doBootLog">
insert into boot_log (class)
values( #{strClass} )
</insert>
</mapper>
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bootlog': Unsatisfied dependency expressed through field 'menuDaoV2'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'menuDaoV2' defined in file [C:\Users\mins1\OneDrive\Desktop\Sailing_jsp\build\classes\java\main\com\boot\sailing_jsp\v2\dao\MenuDaoV2.class]: Cannot resolve reference to bean 'sqlSessionTemplate' while setting bean property 'sqlSessionTemplate'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionTemplate' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.io.IOException: Failed to parse mapping resource: 'file [C:\Users\mins1\OneDrive\Desktop\Sailing_jsp\build\resources\main\sqlmapper\v2\CoffeeMenuV2.xml]'
답변 1
0
안녕하세요, 인프런 AI 인턴입니다. mins199600님.
현재 발생하는 오류는 MyBatis의 Mapper XML 파일(CoffeeMenuV2.xml)에서 문제가 발생하여 SqlSessionFactory 생성에 실패한 것으로 보입니다. 주로 XML 파일의 경로 오류나 XML 문법 문제로 인해 발생합니다. 아래에서 해결 방법을 제안드립니다.
주요 해결 방법
XML 경로 확인:
- 오류 메시지를 보면
CoffeeMenuV2.xml이 잘못된 경로에 있거나, 경로가 올바르지 않을 가능성이 큽니다. 이 파일이src/main/resources/sqlmapper/v2경로에 정확히 위치해 있는지 확인하세요.
- 오류 메시지를 보면
XML 파싱 오류:
- XML 파일의 문법 오류가 있는지 확인하세요.
<if>나<foreach>등의 태그가 제대로 닫혀 있는지, 또는 특수 문자가 제대로 인코딩되어 있는지 확인하시기 바랍니다.
- XML 파일의 문법 오류가 있는지 확인하세요.
Mapper 등록 여부 확인:
MenuDaoV2에 해당되는 Mapper가 Spring Boot에 의해 제대로 등록되어 있는지 확인해야 합니다.@MapperScan("com.boot.sailing_jsp.v2.dao")어노테이션이SpringBootApplication클래스에 적용되어 있는지 확인합니다.
Logback 설정 확인:
- SQL 로그 등을 확인하기 위한 Logback 설정이 되어 있는지도 살펴보세요. 로그를 참고하여 어떤 단계에서 문제가 발생하는지 확인할 수 있습니다.
- SQL 로그 등을 확인하기 위한 Logback 설정이 되어 있는지도 살펴보세요. 로그를 참고하여 어떤 단계에서 문제가 발생하는지 확인할 수 있습니다.
이 문제와 유사한 다른 사례들이 포함된 질문을 참조하시면서 문제를 해결하시기를 권합니다. 관련된 질문은 다음과 같습니다:
근본적인 문제 해결 방법을 위해 위의 체크리스트를 따라가며 문제를 해결해보세요. 이해가 어려우시다면 추가적인 정보나 오류 로그를 제공해주시면 더 세부적으로 도와드리겠습니다.
저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다. 현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏 추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.
마이바티스 환경설정 조회하기 강의 부분에서 메뉴부분에러
0
57
2
자바 8버전이 선택지에 없는데 어떻게 하죠
0
71
2
zip파일 다운받아서 풀었는데도 계속 오류가 생기네요
0
182
2
가격 수정만 자꾸 에러페이지로 갑니다...ㅜ
0
266
2
타임리프 > jsp
0
96
1
File imprt 어떤거 해야하죠?
0
127
1
검색기능이 안됩니다
0
141
2
검색기능이 안됩니다
0
173
3
500에러
0
168
2
v2 객체 만드는중 입니다
0
123
2
오류가 자꾸 나는데 왜이러는 걸까요?ㅠㅠ
0
239
5
오류가 왜 나는건지 모르겠어요
0
150
2
스프링 부트 버전
0
168
2
log.info가 적용이 안되는 문제
0
171
1
Spring Boot에서 jsp 연동 오류
0
317
1
7장 insert mapper erro 문의합니다
1
246
2
선생님 혹시 파일업로드도 알려주실수있나여?
2
593
1
선생님 혹시 세션하고 쿠키 부분 언제쯤 올려주실수있나여?
1
195
1
스프링 부트 2.x 버전 지원 중단, myBatis 추가가 안돼요
0
879
1
커뮤니티 버전에서 스프링 부트를 선택할수 없습니다.
1
346
1
안녕하세요 Ajax강의 잘듣고있습니다. 다름이 아니라 Ajax로 검색할떄 시작일이나 종료일 고객명과 같은 검색조건을 어떻게 구현해야하는지 고민을해보다 질문드립니다.
1
346
2
DB 생성시 발생 에러 관련! "Can't create table" "Error No 150. "Foreign key constraint is incorrectly formed")
1
525
0
int i = menuService.doInsert(coffee,kind,price); 이 코드 질문있어요
1
375
1
@Data 인식 문제
0
286
2





