mybatis:
config: mybatis-config.xml // config 위치 : static 바로 아래
type-aliases-package: kia.com.mybatistest.model // dao,dto가 위치한 곳
mapper-locations: mybatis/mapper/*.xml // mapper를 위한 xml 파일이 위치한 곳 ( static 아래가 아닌 resources 아래 )
Mapper interface 작성
@Repository
@Mapper
public interface UserMapper {
List<UserDto> getAllUserDataList();
}
public interface UserServiceInterface {
public List<UserDto> getAllUserDataList();
}
Service implement 작성
@Service
@RequiredArgsConstructor
public class UserService implements UserServiceInterface {
private final UserMapper userMapper;
@Override
public List<UserDto> getAllUserDataList() {
return userMapper.getAllUserDataList();
}
}
Test Controller 구성
@RequiredArgsConstructor
@RestController
public class MemberTestController {
private final UserService userService;
@GetMapping("/user/test")
public List<UserDto> getAllDataList() {
return userService.getAllUserDataList();
}
}