JSCODE Logo
프로그래밍 과외블로그후기멘토진
회사명 : JSCODE대표 : 박재성사업자 등록번호 : 244-22-01557통신판매업 : 제 2023-인천미추홀-0381 호
학원 명칭 : 제이에스코드(JSCODE)원격학원학원설립ㆍ운영 등록번호 : 제6063호

서울특별시 구로구 경인로 20가길 11(오류동, 아델리아)

Copyright ⓒ 2025 JSCODE - 최상위 현업 개발자들의 프로그래밍 교육 All rights reserved.

이용약관개인정보처리방침
← 블로그 목록으로 돌아가기

Redis를 추가하기 전 기본적인 Spring Boot 프로젝트 셋팅하기

JSCODE 박재성
JSCODE 박재성
2025-12-06
author
JSCODE 박재성
category
Redis
createdAt
Dec 6, 2025
series
비전공자도 이해할 수 있는 Redis 입문/실전
slug
spring-boot-basic-setup
type
post
updatedAt
Dec 6, 2025 04:33 AM

✅ 기본 Spring Boot 프로젝트 셋팅하기

동일한 환경에서 실습을 진행하기 위해 아래 버전을 사용할 것을 권장한다. - Spring Boot는 3.x.x 버전 - MySQL 8.x 버전 - JDK 17
 
  1. Spring Boot 프로젝트 셋팅
    1. start.spring.io
      https://start.spring.io/
      notion image
      • Java 17 버전을 선택하자. 아래 과정을 Java 17 버전을 기준으로 진행할 예정이다.
      • Dependencies는 Spring Boot DevTools, Spring Web, Spring Data JPA, MySQL Driver를 선택해라.
       
  1. 불필요한 테스트 코드 삭제
    1. notion image
       
  1. application.yml에 DB 연결을 위한 정보 작성하기
    1. 이 예제에서는 기존에 있는 application.properties를 지우고 application.yml을 생성했다.
      application.yml
      # local 환경 spring: profiles: default: local datasource: url: jdbc:mysql://localhost:3306/mydb username: root password: password driver-class-name: com.mysql.cj.jdbc.Driver jpa: hibernate: ddl-auto: update show-sql: true
       
  1. Board 엔티티 만들기
    1. Board
      @Entity @Table(name = "boards") public class Board { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String title; private String content; @CreatedDate @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss") @JsonSerialize(using = LocalDateTimeSerializer.class) @JsonDeserialize(using = LocalDateTimeDeserializer.class) private LocalDateTime createdAt; public Long getId() { return id; } public String getTitle() { return title; } public String getContent() { return content; } public LocalDateTime getCreatedAt() { return createdAt; } }
 
  1. 기본 Controller, Service, Repository 만들기
    1. BoardController
      @RestController @RequestMapping("boards") public class BoardController { private BoardService boardService; public BoardController(BoardService boardService) { this.boardService = boardService; } @GetMapping() public List<Board> getBoards( @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int size ) { return boardService.getBoards(page, size); } }
       
      BoardService
      @Service public class BoardService { private BoardRepository boardRepository; public BoardService(BoardRepository boardRepository) { this.boardRepository = boardRepository; } public List<Board> getBoards(int page, int size) { Pageable pageable = PageRequest.of(page - 1, size); Page<Board> pageOfBoards = boardRepository.findAllByOrderByCreatedAtDesc(pageable); return pageOfBoards.getContent(); } }
BoardRepository
public interface BoardRepository extends JpaRepository<Board, Long> { Page<Board> findAllByOrderByCreatedAtDesc(Pageable pageable); }
 
 

✅ 더미 데이터 넣기

-- 높은 재귀(반복) 횟수를 허용하도록 설정 -- (아래에서 생성할 더미 데이터의 개수와 맞춰서 작성하면 된다.) SET SESSION cte_max_recursion_depth = 1000000; -- boards 테이블에 더미 데이터 삽입 INSERT INTO boards (title, content, created_at) WITH RECURSIVE cte (n) AS ( SELECT 1 UNION ALL SELECT n + 1 FROM cte WHERE n < 1000000 -- 생성하고 싶은 더미 데이터의 개수 ) SELECT CONCAT('Title', LPAD(n, 7, '0')) AS title, -- 'Title' 다음에 7자리 숫자로 구성된 제목 생성 CONCAT('Content', LPAD(n, 7, '0')) AS content, -- 'Content' 다음에 7자리 숫자로 구성된 내용 생성 TIMESTAMP(DATE_SUB(NOW(), INTERVAL FLOOR(RAND() * 3650 + 1) DAY) + INTERVAL FLOOR(RAND() * 86400) SECOND) AS created_at -- 최근 10년 내의 임의의 날짜와 시간 생성 FROM cte;
  • 위 SQL문은 MySQL 8.0부터 사용이 가능하다.
 
 
 
 
 
 
 
 
author
category
Redis
createdAt
series
비전공자도 이해할 수 있는 Redis 입문/실전
slug
type
series-footer
updatedAt
Dec 6, 2025 04:33 AM
📎
이 글은 비전공자도 이해할 수 있는 Redis 입문/실전 (조회 성능 최적화편) 강의의 수업 자료 중 일부입니다.