
๐ To Do List

๐ฉ๐ป๐ป Today I Lean ...
Local ๋ฐ Test ํ๊ฒฝ์๋ง ๊ฐ ์ค์ ํ๊ธฐ

playground๋ ํ ์คํธ์ฉ์ด๋ผ ์ด์ํ๊ฒฝ์๋ ๋ฐ์๋๋ฉด ์ ๋๊ณ , local์ด๋ test ํ๊ฒฝ์์๋ง ์ค์ ๋์ด์ผ ํ๋ ๊ฐ์ด๋ผ
environment ๊ฐ์ฒด์ buildList๋ฅผ ์ด์ฉํ์ฌ ๋ฆฌํฉํ ๋ง์ ์งํํด๋ณด์๋ค.
environment ๊ฐ์ฒด๋ ์ด๋ค ํ๊ฒฝ์ธ์ง ๊ตฌ๋ถํ๊ธฐ ์ํด์ ์ฌ์ฉ๋๊ณ , ํ ์คํธ ๋ฐ ๊ฐ๋ฐ ์งํํ๋ฉด์ ์กฐ๊ฑด์ด ์ถ๊ฐ๋ ๊ฑธ ๋๋นํด์ add()ํ๊ธฐ ์ ์ฉํ buildList๋ฅผ ์ด์ฉํ๋ค.
Spring Environment ๊ฐ์ฒด
์ฃผ์ ๊ธฐ๋ฅ 1. ํ๋กํผํฐ ๊ฐ ์กฐํ
val url = environment.getProperty("spring.datasource.url")
์ฃผ์ ๊ธฐ๋ฅ 2. ํ๋กํ์ผ ํ์ธ
if (environment.acceptsProfiles(Profiles.of("test"))) {
// test ํ๊ฒฝ์ผ ๋๋ง ์คํ
}
Kotlin - buildList
val x = listOf('b', 'c')
val y = buildList() {
add('a')
addAll(x)
add('d')
}
println(y) // [a, b, c, d]
- ์ฝ๊ธฐ ์ ์ฉ ๋ฆฌ์คํธ๋ฅผ ๋ง๋๋ Kotlin ํจ์
- ๋ด๋ถ์ ์ผ๋ก๋ MutableList๋ฅผ ๋ง๋ค์ด์ ์์๋ฅผ ์ถ๊ฐํ ํ ์ด ๋ฆฌ์คํธ๋ฅผ ์ฝ๊ธฐ ์ ์ฉ List๋ก ๋ณํํด ๋ฐํํ๋ค.
๋๋ณด๊ธฐ
MutableList<E> ๋ ์์๋ฅผ ์์ ํ ์ ์๋ ๋ฆฌ์คํธ ์ปฌ๋ ์ ์ ๋ํ๋ด๋ ์ธํฐํ์ด์ค
(์ถ์ฒ: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/build-list.html)
'Today I Learned ๐ง' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| [TIL-20260127] @AuthenticationPrincipal , Swagger JWT ์ธ์ฆ ์ค์ (0) | 2026.01.27 |
|---|---|
| [TIL-20260124] Spring Batch Reader ๊ตฌํ (0) | 2026.01.24 |
| [TIL-20260118] JPA ๋ณ๊ฒฝ ๊ฐ์ง (Dirty Checking) (3) | 2026.01.18 |
| [TIL-20260117] Spring JPA ์ปฌ๋ผ์ ์ฝ๋ฉํธ ๋ฌ๊ธฐ (0) | 2026.01.17 |
| [TIL-260116] Spring Stomp ์ง๋ ฌํ, Kotlin์์ ์์ ๋ค๋ฃจ๊ธฐ (0) | 2026.01.16 |