Spring Boot CRUD API ๊ตฌํ
by rlaehddnd0422๊ฐ์
- ๋ช ์นญ : Spring Boot ๊ฒ์ํ API ๊ตฌํ
- ๊ฐ๋ฐ ์ธ์ด : Java 11
- ๊ฐ๋ฐ ํ๊ฒฝ : Spring Boot 2.7.12
- ๋ฐ์ดํฐ๋ฒ ์ด์ค : H2
- ํ์๊ด๋ฆฌ ํด : GitHub
- ๋ฉ์ธ ๊ธฐ๋ฅ
- ๊ฒ์ํ - CRUD ๊ธฐ๋ฅ, ํ์ด์ง, ๊ฒ์
- ๋๊ธ - CRUD ๊ธฐ๋ฅ
- ํ์ - Security ํ์๊ฐ์ , ๋ก๊ทธ์ธ, ํ์์ ๋ณด ์์ , ์ ํจ์ฑ ๋ฐ ์ค๋ณต ๊ฒ์ฌ ( ์ถํ Security ํ์ต ์ดํ ์งํ ์์ )
๋ฐ์ดํฐ ๋ฒ ์ด์ค ์ค๊ณ
API ์ค๊ณ - CRUD
๊ฒ์ํ ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ RESTful API ํด๋น API๋ HTTP ํ๋กํ ์ฝ์ ์ฌ์ฉํ๋ฉฐ, JSON ํ์์ ๋ฐ์ดํฐ๋ฅผ ์ฃผ๊ณ ๋ฐ์ต๋๋ค.
Board
๊ธฐ๋ฅ ๋ฉ์๋ URL RETURN TYPE
๋จ๊ฑด ์กฐํ ์์ฒญ | GET | /boards/{id} | BoardResponseDtos |
์ ์ฒด ์กฐํ ์์ฒญ ( ํ์ด์ง ์ ์ฉ ) | GET | /boards?page={id} | BoardResponseDtos |
์ ์ฒด ์กฐํ ์์ฒญ | GET | /boards | BoardResponseDtos |
๊ฒ์๋ฌผ ์์ฑ | POST | /boards | BoardResponseDto |
๊ฒ์๋ฌผ ์์ | PUT | /boards/{id} | BoardResponseDto |
๊ฒ์๋ฌผ ์ญ์ | DELETE | /boards/{id} | “๊ธ ์ญ์ ์๋ฃ” |
Member
๊ธฐ๋ฅ ๋ฉ์๋ URL RETURN TYPE
ํ์ ๋ฑ๋ก | POST | /member/save | MemberResponseDto |
ํ์ ์์ | PATCH | /member/patch/{id} | MemberResponseDto |
ํ์ ์ญ์ | DELETE | /members | "ํ์ ์ญ์ ์๋ฃ" |
Comment
๊ธฐ๋ฅ ๋ฉ์๋ URL RETURN TYPE
๋๊ธ ๋ฑ๋ก | POST | /boards/{boardId}/comment | CommentResponseDto |
๋๊ธ ์์ | PATCH | /boards/comment/{commentId} | CommentResponseDto |
๋๊ธ ์ญ์ | DELETE | /boards/comment/{commentId} | "๋๊ธ ์ญ์ ์๋ฃ" |
๋๊ธ ์กฐํ | GET | /{boardId}/comment | CommentResponseDtos |
Pre-setting
- build.gradle (dependencies)
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springframework.boot:spring-boot-starter-validation'
- application.yml (H2 Database - dataSource)
spring:
datasource:
url: jdbc:h2:tcp://localhost/~/board
username: sa
password:
driver-class-name: org.h2.Driver
jpa:
hibernate:
ddl-auto: create
default_batch_fetch_size: 1000
properties:
hibernate:
show_sql: true
format_sql: true
logging.level:
org.hibernate.SQL: debug
์์ธํ ์ฝ๋๋ ์๋๋ฅผ ์ฐธ๊ณ ํด์ฃผ์ธ์
'๐ Backend' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Spring Boot CRUD API ๊ตฌํ (2) - Repository, Service, Controller ๊ณ์ธต ๊ตฌํ (Member) (0) | 2023.05.26 |
---|---|
Spring Boot CRUD API ๊ตฌํ (1) - ์๊ตฌ์ฌํญ ๋ถ์, ๋ฐ์ด๋ฒํ ์ด์ค ์ค๊ณ, ๋๋ฉ์ธ ์ค๊ณ (0) | 2023.05.26 |
Spring / ์ง๊ธ๊น์ง ์ฌ์ฉํ ์ด๋ ธํ ์ด์ ์ ๋ฆฌ @ (0) | 2023.02.20 |
Spring / Web ์ค์ฝํ (0) | 2023.02.13 |
Spring / Bean Scope (0) | 2023.02.11 |
๋ธ๋ก๊ทธ์ ์ ๋ณด
Study Repository
rlaehddnd0422