โจ Gradation header generated by Hong-JunHyeok
์๋ ํ์ธ์. ์ ์งํ์ ๋๋ค.
๋งค๋ฒ ์ ํ๋ก์ ํธ๋ฅผ ๊ฐ๋ฐํ๋ ค๊ณ ํ๋ฉด ์ด๊ธฐ ํ๊ฒฝ ์ธํ
๋๋ฌธ์ ๋ง์ ์๊ฐ์ ์ฐ๊ณค ํ๋๋ฐ์.
์ ๊ฐ ๋ง๋ ๋ฐ๋ชจ ์ ํ๋ฆฌ์ผ์ด์
์ ์ต๋ํ ์คํ๋ง ์ ํ๋ฆฌ์ผ์ด์
์ ๊ณตํต์ผ๋ก ์ฌ์ฉ๋๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ์ค์ ๊ฐ์ ๋ฃ์์ต๋๋ค.
์ ๋ฐ๋ชจ๋ฅผ ์ด์ฉํด๋ณด๋ ์ด๋ฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ํ์ํ ๊ฒ ๊ฐ๋ค, ์ด๋ฐ ์ค์ ๊ฐ๋ ํ์ํ ๊ฒ ๊ฐ๋ค. ํ๋ ๋ถ๋ถ issue๋ก ์ ์ํด์ฃผ์ธ์.
๊ฐ์ฌํฉ๋๋ค.
- Dependencies
Spring Web
Spring Data JPA
querydsl-jpa
Lombok
Validation
H2 Database
Mockito
Swagger3, Swagger-ui
Spring REST Docs (Junit 5 + Mockito)
Spring REST Docs API specification Integration
-
git clone
git clone https://github.com/jyeonjyan/springboot-starter [your project name]
-
IntelliJ ์์ ํ๋ก์ ํธ ์ด๋ฆ ๋ฐ๊พธ๊ธฐ
- Go to File >> Project Structure >> Project > Project Name Update project name with its new name
- Exit IntelliJ IDEA
- Edit contents of the following files
- {project_root}/settings.gradle
- {project_root}/.idea/.name (if exists)
- Open IntelliJ IDEA
- Refresh Gradle Project
- Change app package name like
com.app.yourprojectname
- Change app entry point class name like
YourApplication.java
- Run
YourApplication.java
-
์ ํ๋ฆฌ์ผ์ด์ ์ ๊ธฐ๋ณธ์ ์ผ๋ก
8080
ํฌํธ์์ ์คํ๋ผ์. -
H2 Database ์ฌ์ฉํ๋ ๋ฒ
- Embedded and server modes ์ค์นํ DB
- disk-based or in-memory databases ์ธ๋ฉ๋ชจ๋ฆฌ DB
-
Querydsl ์ฌ์ฉํ๋ ๋ฒ
- IntelliJ ํ๊ฒฝ์ค์ ์์ annotation processing ์ ํ์ฑํ ํด์.
- Q-class๋ฅผ ์์ฑํ๋ ค๋ฉด Gradle ์์
์ฐฝ์์
Gradle/Tasks/other/compileQuerydsl.sh
task๋ฅผ ๋๋ฅด๊ฑฐ๋./gradlew clean build
๋ช ๋ น์ด๋ฅผ ์ด์ฉํด์. - Q-class๋
project/build/generated/querydsl/
์ฌ๊ธฐ์ ์์ฑ๋ผ์. - ์์ธํ ๋ด์ฉ์ ์ฌ๊ธฐ๋ฅผ ์ฐธ๊ณ ํ์ธ์.
-
Swagger ์ฌ์ฉํ๋ ๋ฒ
- Swagger ์ค์ ์
src/main/**/demo/config/SwaggerConfig.java
์ ์์ด์. - ๊ธฐ๋ณธ์ ์ผ๋ก
@Profile("dev")
dev profile ์์๋ง ์ฌ์ฉ ๊ฐ๋ฅํ๊ฒ ํด๋์ด์. - Swagger๋
http://localhost:8080/swagger-ui.html
์ ๋ง์ดํธ ๋ผ ์์ด์. - ์์ธํ ๋ด์ฉ์ ์ฌ๊ธฐ๋ฅผ ์ฐธ๊ณ ํ์ธ์.
- Swagger ์ค์ ์
-
Spring REST Docs ์ฌ์ฉํ๋ ๋ฒ
- Swagger ๋ API ๋ฌธ์ํ ๋๊ตฌ๋ก ์ฌ์ฉํ๊ธฐ์๋ ์์ฌ์ด ๋ถ๋ถ์ด ๋ง์์. ๊ทธ๋์ REST Docs์ ์ค๋นํ์ด์.
- Controller Test ๋ฅผ ํต๊ณผํด์ผ์ง๋ง ๋ฌธ์๊ฐ ๋ง๋ค์ด์ ธ์. ์์ ๋ MockMvc, mockito, junit5 ๋ก ํ ์คํธ ํ์ด์.
- ํ
์คํธ๊ฐ ํต๊ณผํ๋ฉด
build/generated-snippets/**
์ ์ค๋ํซ(.adoc)๋ค์ด ์์ฑ๋ผ์. src/docs/asciidoc/**.adoc
์ผ๋ก API spec ํ์ด์ง๋ฅผ ๊ตฌ์ฑํด์ฃผ์ธ์..adoc
ํ์ผ ์์ฑ ๋ฐฉ๋ฒ์ ๋ํ ์์ธํ ๋ด์ฉ์ ์ฌ๊ธฐ๋ฅผ ์ฐธ๊ณ ํ์ธ์.
./gradlew build
์build/asciidoc/html5/**
์ html๋ก ๋ณํ๋ API spec ํ์ด์ง๊ฐ ์์ฑ๋ ๊ฑฐ์์.
-
Spring REST Docs API spec ์ฌ์ฉํ๋ ๋ฒ