Description:
Field bookMapper in kwang.ho.service.book.BookServiceImpl required a bean of type 'kwang.ho.mapper.book.BookMapper' that could not be found.
Action:
Consider defining a bean of type 'kwang.ho.mapper.book.BookMapper' in your configuration.
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
위와 같은 오류로 bean을 못 찾는다고 하는데 원인이 뭘까요
1. BookServiceImpl.java
package kwang.ho.service.book;
@Service
public class BookServiceImpl implements BookService {
@Autowired
private BookMapper bookMapper;
@Override
public List<BookDto> selectBookListWithPaging(PagingVO pagingVO) throws Exception {
return bookMapper.selectBookListWithPaging(pagingVO);
}
}
2. BookService.interface
package kwang.ho.service.book;
public interface BookService {
List<BookDto> selectBookListWithPaging(PagingVO pagingVO) throws Exception;
}
3. BookMapper.interface
package kwang.ho.mapper.book;
public interface BookMapper{
List<BookDto> selectBookListWithPaging(PagingVO pagingVO) throws Exception;
}
4. BookController.java
package kwang.ho.controller.book;
@Controller
@RequiredArgsConstructor
public class BookController {
private final BookService bookService;
@RequestMapping("/bookList.do")
public String selectBookListWithPaging(PagingVO pagingVO, Model model
, @RequestParam(value="nowPage", required=false)String nowPage
, @RequestParam(value="cntPerPage", required=false)String cntPerPage, BookDto bookDto) throws Exception {
model.addAttribute("list", bookService.selectBookListWithPaging(pagingVO));
return "/bookList";
}
}
5. bookMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTO Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="kwang.ho.mapper.book.BookMapper">
<!-- 도서게시판 목록 조회 -->
<select id="selectBookListWithPaging" parameterType="kwang.ho.dto.board.PagingVO" resultType="kwang.ho.dto.book.BookDto">
<![CDATA[
select * from board;
]]>
</select>
</mapper>
6. HoApplication(실행파일)
package kwang.ho;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class HoApplication {
public static void main(String[] args) {
SpringApplication.run(HoApplication.class, args);
}
}