본문 바로가기
백엔드/Spring

스프링 자주하는 실수

by shinyou1024 2020. 5. 20.

스프링을 공부하다가 디버깅했던 경험을 적습니다.

계속 업데이트 됩니다... 아마?

404 에러

컨트롤러

  • @Controller를 붙였는지
  • @RequestMapping을 잘 적었는지

root-context.xml

  • 컨트롤러를 등록했는지

Context:component-scan is not bound

[오류]context:component-scan" is not bound

index.jsp가 바로 나오게 하고싶다!

value를 "/"으로 변경!! ⇒ 실패...!

<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean>

MyBatis

Caused by가 달린 줄만 잘 보면 된다

맨 오른쪽에 가면 Cannot find class : com.shinyou.hr.to.Employee 이런 식으로 쓰여 있다

 

servlet-context.xml 에러

Mapped Statements collection does not contain value for​ ~

  • DAOImpl에 작성된 이름과 mapper.xml에 작성된 이름이 다를 경우

예시 : DAO의 selectList내의 파라미터와 mapper의 id와 일치해야 한다

EmployeeRepoImpl.java

@Override
    public List<Employee> selectAll(){
        return session.selectList("employee.searchAll");
    }

product.xml

<!-- 전체 상품 목록 조회 -->
    <select id="selectAll" resultType="Employee">
        select *
        from employee
    </select>

'백엔드 > Spring' 카테고리의 다른 글

Spring Framework 개념  (0) 2020.05.19

댓글