`gradle dependencies`์๋ api ์ ์ธ๊ณผ implementation ์ ์ธ์ด ์กด์ฌํ๋ค.
ํนํ ๋ฉํฐ๋ชจ๋ ๊ตฌ์กฐ์ธ ํ๋ก์ ํธ์ ๊ฒฝ์ฐ ๋ ๊ฐ์ง๋ฅผ ํจ๊ป ์ฐ๋ ๊ฒฝ์ฐ๊ฐ ๋ง๊ธฐ ๋๋ฌธ์ ์ ๋ฆฌ๋ฅผ ํด๋๋ ค๊ณ ํ๋ค!
๐ api, implementation
dependencies {
api 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
}
api ์ ์ธ์ ์ฌ์ฉํ๋ฉด ์ ์ธ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ ํด๋น ๋ชจ๋์ ์์กดํ๋ ๋ชจ๋์ ์ปดํ์ผ, ๋ฐํ์์ ํด๋์คํจ์ค์ ๋ชจ๋ ํฌํจ๋๋ค.
โป ์์์ spring-boot-starter-data-jpa๋ api ์ ์ธ์ด๊ธฐ ๋๋ฌธ์, ์ด ๋ชจ๋์ ์์กดํ๋ ๋ค๋ฅธ ๋ชจ๋๋ค๋ ํด๋น ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ ์ ์๊ฒ ๋๋ค.
ํ์ง๋ง api ์ ์ธ์ ๋จ์ฉํ๊ฒ ๋๋ฉด ๋ชจ๋๊ฐ ๊ฒฐํฉ์ด ์ฆ๊ฐํ๊ฒ ๋๊ณ , ๋ณ๊ฒฝ ์ ํ๊ฐ ์ปค์ง๋ค.
implementation ์ ์ธ์ ํ์ฌ ๋ชจ๋ ๋ด์์๋ง ์ปดํ์ผ, ๋ฐํ์์ ์ฌ์ฉ๋๊ณ ์ธ๋ถ์๋ ๊ณต๊ฐ๋์ง ์๋๋ค.
โป ์์์ spring-boot-starter-security๋ ์ด ๋ชจ๋์ ์์กดํ๋ ๋ค๋ฅธ ๋ชจ๋๋ค์์ ์ฌ์ฉํ ์ ์๊ณ , ๊ฐ๊ฐ ์ ์ธ์ ๋ค์ ํด์ค์ผ ํ๋ค.
๐ฉ ๋ชจ๋ ์ ์ธํ๊ธฐ
`core`๋ชจ๋๊ณผ `service`๋ชจ๋์ด ์๊ณ , `service`๋ชจ๋์์ `core`๋ชจ๋์ ๊ฐ์ ธ๋ค ์ฐ๋ ค๊ณ ํ๋ค.
// core
plugins {
id 'java-library'
}
dependencies {
api 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-security'
}
// service
dependencies {
implementation project(":core")
implementation 'org.springframework.boot:spring-boot-starter-security'
}
core ๋ชจ๋์์๋ `java-library` ํ๋ฌ๊ทธ์ธ๋ ์ ์ธ์ ํด์ค์ผ ํ๋ค.
์ดํ service ๋ชจ๋์์ `implementation project`๋ฅผ ํตํด core์ ์๋ api ์ ์ธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค์ ๊ฐ์ ธ์ฌ ์ ์๋ค.
`spring-boot-starter-security`๋ core์์ implementation์ผ๋ก ์ ์ธ๋์๊ธฐ ๋๋ฌธ์
service ๋ชจ๋์์ ์ฌ์ฉํ๋ ค๋ฉด core ๋ชจ๋์์ api ์ ์ธ์ผ๋ก ๋ณ๊ฒฝํ๊ฑฐ๋, service ๋ชจ๋์์ ์ฌ์ ์ธ ํด์ผ ํ๋ค.
'Backend > Spring' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| [QueryDSL] QueryDSL ์ ์ฉ ๊ธฐ์ค (0) | 2026.01.27 |
|---|---|
| [Spring Data JPA] Stream Filter ํ Page๋ก ๋ณํํ๊ธฐ (0) | 2025.05.23 |
| [Spring Data JPA] ํ์ด์ง(Pageable)๊ณผ ์ ๋ ฌ(Sort) ํ ๋ฒ์ ์ฒ๋ฆฌํ๊ธฐ (0) | 2025.04.30 |