Migration in jdk Amazon corretto 21 - 3sam5oh/webtoon-search-service GitHub Wiki

โœˆ๏ธ Migration in jdk Amazon corretto 21

1. Amazon Corretto 21.0.3 ๋‹ค์šด๋กœ๋“œ ๋ฐ ์„ค์น˜

(intellij ํ†ตํ•ด ๋‹ค์šด๋กœ๋“œ๋ฅผ ํ•  ์‹œ 2๋ฒˆ๋ถ€ํ„ฐ ๋ณด์‹œ๋ฉด๋ฉ๋‹ˆ๋‹ค.)

  • Amazon Corretto ๋‹ค์šด๋กœ๋“œ
    • Amazon Corretto ๊ณต์‹ ์›น์‚ฌ์ดํŠธ์—์„œ Amazon Corretto 21.0.3์„ ๋‹ค์šด๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค.
    • ์šด์˜์ฒด์ œ์— ๋งž๋Š” ์„ค์น˜ ํŒŒ์ผ์„ ์„ ํƒํ•˜์—ฌ ๋‹ค์šด๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค.

2. Amazon Corretto ์„ค์น˜

  • ๋‹ค์šด๋กœ๋“œํ•œ ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜์—ฌ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

    • ์„ค์น˜ ๊ฒฝ๋กœ๋ฅผ ๊ธฐ์–ตํ•ด๋‘ก๋‹ˆ๋‹ค.
  • ์ €์žฅ ์œ„์น˜๋Š” ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์„ค์ • ํ•ด๋‘” ๊ฒฝ์šฐ ํ•ด๋‹น ๊ฒฝ๋กœ์— ์ƒˆ๋กœ์šด ๋””๋ ‰ํ† ๋ฆฌ๋กœ ๋ณ€๊ฒฝํ•˜๊ณ  ํ•ด๋‹น ์œ„์น˜์— ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.

    • ์ƒˆ๋กœ์šด ๋””๋ ‰ํ† ๋ฆฌ๊ฐ€ ์—†๋‹ค๋ฉด ์ƒ์„ฑ ํ›„ ํ•ด๋‹น ์œ„์น˜์— ์ €์žฅํ•ฉ๋‹ˆ๋‹ค

image

  • IntelliJ๋ฅผ ํ™œ์šฉ ํ•˜๋Š” ๊ฒฝ์šฐ (21 ๋ฒ„์ „ ์„ ํƒ ํ›„, Amazon Corretto 21.0.3 Vender ์„ ํƒ)

image image

3. IntelliJ IDEA์—์„œ Project SDK ์„ค์ •

  • IntelliJ IDEA ์‹คํ–‰
    • IntelliJ IDEA๋ฅผ ์‹คํ–‰ํ•˜๊ณ  ํ”„๋กœ์ ํŠธ๋ฅผ ์—ฝ๋‹ˆ๋‹ค.
  • Project Structure ์—ด๊ธฐ:
    • ๋‹จ์ถ•ํ‚ค Ctrl + Alt + Shift + S๋ฅผ ๋ˆŒ๋Ÿฌ Project Structure ์ฐฝ์„ ์—ฝ๋‹ˆ๋‹ค.
  • Project SDK ์„ค์ •:
    • ์ขŒ์ธก ๋ฉ”๋‰ด์—์„œ Project๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.
    • Project SDK ๋“œ๋กญ๋‹ค์šด ๋ฉ”๋‰ด์—์„œ Add SDK๋ฅผ ์„ ํƒํ•œ ํ›„ JDK๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.
    • Amazon Corretto 21.0.3์ด ์„ค์น˜๋œ ๊ฒฝ๋กœ๋ฅผ ์„ ํƒํ•˜์—ฌ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
    • Project language level์ด SDK default๋กœ ์„ค์ •๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

4. Gradle Settings ์—ด๊ธฐ

  • ๋ฉ”๋‰ด์—์„œ File > Settings๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค. (macOS์˜ ๊ฒฝ์šฐ IntelliJ IDEA > Preferences)
  • ์ขŒ์ธก ๋ฉ”๋‰ด์—์„œ Build, Execution, Deployment > Build Tools > Gradle์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.
  • Gradle JVM ๋“œ๋กญ๋‹ค์šด ๋ฉ”๋‰ด์—์„œ Amazon Corretto 21.0.3์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค (Project SDK๋ฅผ ์„ค์ • ํ–ˆ๋‹ค๋ฉด ๋””ํดํŠธ ๊ฐ’์„ ์„ ํƒํ•ด๋„ ๊ดœ์ฐฎ์Šต๋‹ˆ๋‹ค). image

5. build.gradle ํŒŒ์ผ ์ˆ˜์ •

  • Java Toolchain ์„ค์ • ๋ณ€๊ฒฝ
    • build.gradle ํŒŒ์ผ์„ ์—ด๊ณ  Java Toolchain ์„ค์ •์„ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.
java {
   toolchain {
       languageVersion = JavaLanguageVersion.of(21)
   }
}
  • (Load gradle ํ™•์ธํ•ด ์ฃผ์„ธ์š” - ์ฝ”๋ผ๋ฆฌ ์ด๋ฏธ์ง€ ํด๋ฆญ) image
  1. ํ”„๋กœ์ ํŠธ ๋นŒ๋“œ ๋ฐ ํ…Œ์ŠคํŠธ -Gradle ํด๋ฆฐ ๋นŒ๋“œ:
    • ํ„ฐ๋ฏธ๋„์—์„œ ํ”„๋กœ์ ํŠธ ๋ฃจํŠธ ๋””๋ ‰ํ„ฐ๋ฆฌ๋กœ ์ด๋™ํ•œ ํ›„ ๋‹ค์Œ ๋ช…๋ น์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
./gradlew clean build
  • ํ”„๋ก ํŠธ์™€ ๋ฒก์—”๋“œ ํ”„๋กœ์ ํŠธ ํ•จ๊ป˜ ์žˆ๋Š” ๊ฒฝ์šฐ ๋ฒก์—”๋“œ ํ”„๋กœ์ ํŠธ์˜ root ๊ฒฝ๋กœ (ex webtoon-search) ์— ์œ„์น˜ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. image

ํ™˜๊ฒฝ ๋ณ€์ˆ˜๊ฐ€ ์ž˜ ์ ์šฉ๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•ด์„œ CMD (๋˜๋Š” Terminal) ์—์„œ java --version, echo %JAVA_HOME% ๋ช…๋ น์–ด๋ฅผ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜๋œ ๋ฒ„์ „์œผ๋กœ ์ถœ๋ ฅ๋˜๋Š”์ง€ ํ™•์ธํ•ด ์ฃผ์„ธ์š”!

C:\Users\hi>java --version
openjdk 21.0.3 2024-04-16 LTS
OpenJDK Runtime Environment Corretto-21.0.3.9.1 (build 21.0.3+9-LTS)
OpenJDK 64-Bit Server VM Corretto-21.0.3.9.1 (build 21.0.3+9-LTS, mixed mode, sharing)

C:\Users\hi>echo %JAVA_HOME%
C:\Program Files\ojdkbuild\java-21-openjdk-21.0.3

C:\Users\hi>

JAR ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜์—ฌ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ž‘๋™ ์—ฌ๋ถ€๋ฅผ ํ™•์ธ ํ•˜๊ณ  ์‹ถ์„ ์‹œ, jar ํŒŒ์ผ ๋นŒ๋“œ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ํ™•์ธ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

java -jar build/libs/your-application-name.jar

๐Ÿ‘€ ๋„์›€์ด ๋  ์ˆ˜ ์žˆ๋Š” ๋นŒ๋“œ ๊ด€๋ จ ๋ช…๋ น์–ด

  • ๋นŒ๋“œ ๊ณผ์ • ๋กœ๊ทธ
./gradlew build --info
  • ๋นŒ๋“œ ๋””๋ฒ„๊ทธ
./gradlew build --debug
  • Gradle ์บ์‹œ ์ •๋ฆฌ ๋ฐ ์˜์กด์„ฑ ์ƒˆ๋กœ๊ณ ์นจ
gradlew clean --refresh-dependencies
  • Gradle ๋ž˜ํผ ๋ฒ„์ „ ์—…๋ฐ์ดํŠธ
.\gradlew wrapper --gradle-version 8.8
  • Gradle ํ˜„์žฌ ๋ฒ„์ „ ํ™•์ธ & ํŠน์ • ๋ฒ„์ „ ์—…๋ฐ์ดํŠธ & ์ตœ์‹ 
.\gradlew --version
.\gradlew wrapper --gradle-version [version]
.\gradlew wrapper --gradle-version latest

gradle version ํ™•์ธ์„ ์œ„ํ•œ ๋งํฌ