메시리
100
2019-07-09 01:09:54
8
162

mybatis에러 질문입니다.


구글링 아무리 해봐도 해결되지 않아 도움을 요청합니다. ㅜㅜ

스프링을 이용하여 select를 하려고 하는데 자꾸 에러가 생기네요.. 

인터넷에 나오는거 해봤는데.. 안되네요.. namespace오타 등등.. 근데 에러 코드는 자꾸 getMemberList가 없다고하는데.. 저의 눈에는 보이지 않네요.. 

memberForm은 보내지 사용하지 않습니다. 나중에 쓰려고 만들어 놓은 것이구요 혹시 저게 원인인가 해서

없애고 해봤는데도 에러 내용은 시종일관 변하지 않네요.. 


DAO

package com.duk.ballondor.dao;

import javax.annotation.Resource;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import com.duk.ballondor.dto.MemberDto;
import com.duk.ballondor.form.MemberForm;
import java.util.List;

@Repository
public class MemberDao {

	@Resource(name = "sqlSession")
	private SqlSession sqlSession;
	
	private static final String NAMESPACE = "com.duk.ballondor.ballondorMapper.";
	
	public List<MemberDto> getMemberList(MemberForm memberForm) throws Exception {
		
		return sqlSession.selectList(NAMESPACE + "getMemberList", memberForm);
	}
	
}


Service


package com.duk.ballondor.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.duk.ballondor.dao.MemberDao;
import com.duk.ballondor.dto.MemberDto;
import com.duk.ballondor.form.MemberForm;

@Service
public class MemberService {

	@Autowired
	private MemberDao memberDao;
	
	public List<MemberDto> getMemberList(MemberForm memberForm) throws Exception {
		
		return memberDao.getMemberList(memberForm);
	}
}


Controller


package com.duk.ballondor.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.duk.ballondor.dto.MemberDto;
import com.duk.ballondor.form.MemberForm;
import com.duk.ballondor.service.MemberService;

@Controller
@RequestMapping(value="member")
public class memberController {

	@Autowired
	private MemberService memberService;
	
	@RequestMapping(value="/memberList.do")
	public String getMemberList(HttpServletRequest request, HttpServletResponse response) throws Exception {
		
		return "member/signUp";
	}
	
	@RequestMapping(value="/getMemberList.do") 
	@ResponseBody
	public List<MemberDto> getMemberList(HttpServletRequest request, HttpServletResponse response, MemberForm memberForm) throws Exception {
		
		List<MemberDto> memberList = memberService.getMemberList(memberForm);
		
		return memberList;
	}
}


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.duk.ballondor.ballondorMapper">
	
	<select id="getMemberList" resultType="com.duk.ballondor.dto.MemberDto">
		SELECT MEMBER_ID
			 , MEMBER_NAME
		     , MEMBER_PW
		  FROM BALLONDOR.MEMBER;
	</select>
</mapper>

<!-- parameter="com.duk.ballondor.form.MemberForm"  -->


jsp랑

 js는 별 의미 없을 것 같습니다. 단순히 테스트를 위한거라서요.

그래도 혹시 몰라 올리겠습니다.


jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="EUC-KR"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>회원가입</title>
<!-- <link rel="stylesheet" href="css/signUp.css"> -->
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<!-- <script src="js/selectTest.js"></script> -->
<script src="<c:url value="/resources/js/selectTest.js" />"></script>

</head>         
<body>
<div class="container">
	<h1>회원가입</h1>
	
	<div class="label">이름</div>
	<div class="form">
		<input type="text" id="userNm" placeholder="이름을 입력해주세요"/>	
	</div>
	
	<div class="label">아이디</div>
	<div class="form">
		<input type="text" id="userId" placeholder="아이디를 입력해주세요"/>	
	</div>	
	
	<div class="label">비밀번호</div>
	<div class="form">
		<input type="password" id="userPw" placeholder="비밀번호를 입력해주세요"/>	
	</div>
	
	<div class="label">비밀번호확인</div>
	<div class="form">
		<input type="password" id="userCheckPw" placeholder="비밀번호를 입력해주세요"/>	
	</div>	
	
	<button id="signUp">가입하기</button>
</div>
</body>
</html>


js


$(function(){
	
	alert('js 호출 성공');
	$.fn.getMemberList();
});	

$.fn.getMemberList = function() {
	
	alert('js 메서드 호출 성공');
	$.ajax({
		
		type:"GET"
	,	url: "/member/getMemberList.do"
	,	dataType: "JSON"	
	,	success: function(obj) {
		
			$.fn.getMemberListCallback(obj);
		}
	,	error: function(xhr, status, error) {
		
		alert("js 실패");
	}
	});
}
	
$.fn.getMemberListCallback = function(obj) {
	
	alert('js callback 메서드 호출 성공');
	var list = obj;
	var listLen = obj.length;
	
	console.log(list);
	console.log(listLen);
}


	


에러내용

심각: Servlet.service() for servlet [appServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 

### Error querying database.  Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.duk.ballondor.ballondorMapper.getMemberList

### Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.duk.ballondor.ballondorMapper.getMemberList] with root cause

java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.duk.ballondor.ballondorMapper.getMemberList

at org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:888)

at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:721)

at org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:714)

at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:147)

at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)

at com.sun.proxy.$Proxy28.selectList(Unknown Source)

at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230)

at com.duk.ballondor.dao.MemberDao.getMemberList(MemberDao.java:22)

at com.duk.ballondor.service.MemberService.getMemberList(MemberService.java:20)

at com.duk.ballondor.controller.memberController.getMemberList(memberController.java:34)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)

at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)

at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)

at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)

at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)

at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)

at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)

at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)

at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)

at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)

at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)

at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:660)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)

at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:798)

at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)

at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:808)

at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)

at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Thread.java:748)


크롬 개발자 도구 js 에러내용

jquery-1.12.4.js:10254 GET http://localhost:8080/member/getMemberList.do 500
send@jquery-1.12.4.js:10254
ajax@jquery-1.12.4.js:9738
$.fn.getMemberList@selectTest.js:10
(anonymous)@selectTest.js:4
fire@jquery-1.12.4.js:3232
fireWith@jquery-1.12.4.js:3362
ready@jquery-1.12.4.js:3582
completed@jquery-1.12.4.js:3617


도움 부탁드립니다.ㅜㅜ

0
0
  • 답변 8

  • 웃어라포도
    25
    2019-07-09 02:12:14

    config 에 mapper 위치를 제대로 등록하셨나요? 그부분은 안올리셨네요

    0
  • 메시리
    100
    2019-07-09 08:37:22

    root-context

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="configLocation" value="classpath:mybatis-config.xml"/>
        <property name="mapperLocations" value="classpath:mappers/*/*.xml"/>
    </bean>
    
    <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate" destroy-method="clearCache">
            <constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory"/>
    </bean>      


    mybatis-config


    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE configuration 
    PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
    "http://mybatis.org/dtd/mybatis-3-config.dtd>
    <configuration>
    </configuration>


    이렇게 되어 있습니다. 

    새벽2시에 답변을.. 감사합니다.

    0
  • 오로롱이
    1k
    2019-07-09 09:18:22

    com.duk.ballondor.ballondorMapper 여기 인터페이스에 getMemberList 메소드가 없는듯

    0
  • 스우
    98
    2019-07-09 10:22:46

    xml에서 파라미터를 안 준 상태라면 DAO에서 return을 sqlSession.selectList(NAMESPACE + "getMemberList") 바꿔도 계속 에러가 나나요? MemberDTO getter setter도 보여주세요

    0
  • 메시리
    100
    2019-07-09 11:33:59

    memberForm을 없애도 에러가 똑같습니다.


    DTO는 그냥 이렇습니다.


    public class{

     String member_id;

     String member_name;

     String member_pw;


    public String getMember_id() {

      return member_id;

    }

    public void setMember_id(String member_id) {

      this.member_id = member_id;

    }


    public String getMember_name() {

      return member_name;

    }

    public void setMember_name(String member_name) {

      this.member_name = member_name;

    }


    public String getMember_pw() {

      return member_pw;

    }

    public void setMember_pw(String member_pw) {

      this.member_pw = member_pw;

    }

    }


    0
  • 메시리
    100
    2019-07-09 11:34:52

    다시 올릴게요 보기 힘드실까봐. 코드로 올릴게용

    public class{
     String member_id;
    
     String member_name;
    
     String member_pw;
    
    
    
    public String getMember_id() {
      return member_id;
    
    }
    
    public void setMember_id(String member_id) {
      this.member_id = member_id;
    
    }
    
    
    
    public String getMember_name() {
      return member_name;
    
    }
    
    public void setMember_name(String member_name) {
      this.member_name = member_name;
    
    }
    
    
    
    public String getMember_pw() {
      return member_pw;
    
    }
    
    public void setMember_pw(String member_pw) {
      this.member_pw = member_pw;
    
    }
    
    }


    0
  • 스우
    98
    2019-07-09 14:19:16

    지금 mybatis sql 있는 경로가 classpath:mappers/*/*.xml 이 맞나요?

    0
  • 메시리
    100
    2019-07-09 17:11:43

    네 그 부분은 문제없는 것 같아요. 그거는 그전에 /**/*.XML일 때 에러 낫던거를 /*/*바꾸고 해결 됐습니다.

    에러 코드에도 이런 내용은 없는 것 같구요

    0
  • 로그인을 하시면 답변을 등록할 수 있습니다.