๐Ÿƒ Spring Framework๋กœ Web Server ์‹คํ–‰ํ•˜๊ธฐ

Dev_An_Studentยท2024๋…„ 10์›” 18์ผ
1

Java

๋ชฉ๋ก ๋ณด๊ธฐ
4/5
post-thumbnail

์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” Spring Framework๋กœ Web Server๋ฅผ ์‹คํ–‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ๋‹ค๋ค„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.




0. eclipse์— Spring Tools Suite ์„ค์น˜ํ•˜๊ธฐ


๋จผ์ €, ์ดํด๋ฆฝ์Šค๋ฅผ ์‹คํ–‰ํ•ด ์ค๋‹ˆ๋‹ค.




์ดํด๋ฆฝ์Šค๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ๋‚˜์˜ค๋Š” ์ฒซ ํ™”๋ฉด์—์„œ, ์ƒ๋‹จ ๋ฉ”๋‰ด Help -> Eclipse Marketplace๋ฅผ ํด๋ฆญํ•ด ์ค๋‹ˆ๋‹ค.




Eclipse Marketplace ์ฐฝ์ด ์—ด๋ฆฌ๋ฉด, ๊ฒ€์ƒ‰์ฐฝ์— Spring Tools ๋˜๋Š” STS๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

Spring Tools๋ฅผ ๊ฒ€์ƒ‰ํ•˜๋ฉด, ์—ฌ๋Ÿฌ ํ•ญ๋ชฉ์ด ๊ฒ€์ƒ‰์ด ๋ฉ๋‹ˆ๋‹ค.
๊ทธ ์ค‘์—์„œ ๋„ค๋ชจ ๋ฐ•์Šค๊ฐ€ ๊ฐ€๋ฅดํ‚ค๋Š” 2๊ฐ€์ง€ ํ•ญ๋ชฉ์— ๋Œ€ํ•ด ์ž ์‹œ ์•Œ์•„๋ณด๊ณ  ๋„˜์–ด๊ฐ€๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.


1. Spring Tools 3 Add-on for Spring Tools 4 3.9.22.release

  • Spring Tools 3 Add-on์€ ์ฃผ๋กœ ์ด์ „ ๋ฒ„์ „์˜ Spring Tools์™€์˜ ํ˜ธํ™˜์„ฑ์„ ์œ ์ง€ํ•˜๊ฑฐ๋‚˜ ํŠน์ • ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•˜๊ธฐ ์œ„ํ•œ ์šฉ๋„๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ํ˜„์žฌ๋กœ์„œ๋Š” ์ตœ์‹  ๋ฒ„์ „์ธ STS4๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ๋” ์œ ๋ฆฌํ•ฉ๋‹ˆ๋‹ค.

2. Spring Tools 4 (aka Spring Tool Suite 4) 4.25.0 release

  • Spring Tools 4 (STS4)๋Š” Spring Framework์™€ Spring Boot ๊ฐœ๋ฐœ์„ ์œ„ํ•œ ์ตœ์‹  ๋„๊ตฌ์™€ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ์ตœ์‹  Spring ํ”„๋กœ์ ํŠธ์™€ ํ˜ธํ™˜๋˜๋ฉฐ, ์ตœ์‹  ๊ธฐ๋Šฅ์„ ํ™œ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.**

์ถ”์ฒœ

  • Spring Tools 4 (aka Spring Tool Suite 4) 4.25.0 release

  • ์ด์œ 

    • ์ตœ์‹  ๊ธฐ๋Šฅ ๋ฐ ์ง€์›
    • ํ˜ธํ™˜์„ฑ
      • Spring Tools 4๋Š” ์ตœ์‹  Eclipse ๋ฒ„์ „๊ณผ ์ž˜ ํ˜ธํ™˜๋ฉ๋‹ˆ๋‹ค. Eclipse์˜ ์ตœ์‹  ์—…๋ฐ์ดํŠธ์™€ ํŒจํ‚ค์ง€์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋ฉด ์•ˆ์ •์ ์ด๊ณ  ํšจ์œจ์ ์ธ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์„ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
      • Spring Tools 4๋Š” Spring Boot, Spring MVC, Spring Data ๋“ฑ Spring์˜ ๋‹ค์–‘ํ•œ ํ”„๋กœ์ ํŠธ์™€ ์›ํ™œํ•˜๊ฒŒ ํ†ตํ•ฉ๋ฉ๋‹ˆ๋‹ค.
    • ์„ค์น˜ ๋ฐ ์œ ์ง€๋ณด์ˆ˜
      • Spring Tools 4๋Š” Spring ๊ฐœ๋ฐœ์„ ์œ„ํ•œ ํ†ตํ•ฉ๋œ ํ™˜๊ฒฝ์„ ์ œ๊ณตํ•˜๋ฏ€๋กœ, ๋ณ„๋„์˜ ์ถ”๊ฐ€ ์„ค์น˜ ์—†์ด๋„ ๋Œ€๋ถ€๋ถ„์˜ Spring ๊ด€๋ จ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
      • Spring Tools 4๋Š” ์ง€์†์ ์œผ๋กœ ์—…๋ฐ์ดํŠธ๋˜๋ฉฐ, ์ƒˆ๋กœ์šด Spring ๊ธฐ๋Šฅ๊ณผ ๋ฒ„๊ทธ ์ˆ˜์ •์ด ์ •๊ธฐ์ ์œผ๋กœ ๋ฐ˜์˜๋ฉ๋‹ˆ๋‹ค.



์ด๋Ÿฌํ•œ ์ด์œ ๋กœ Spring Tools 4๋ฅผ ์„ ํƒํ•˜์—ฌ ์„ค์น˜ํ•˜๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
Imstall ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.




Install ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅธ ํ›„ ์„ค์น˜ ์˜ต์…˜์€ ๊ธฐ๋ณธ ์„ค์ •์œผ๋กœ ํ•˜๊ณ  ๋„˜์–ด๊ฐ‘๋‹ˆ๋‹ค.




๋ผ์ด์„ ์Šค ์กฐ๊ฑด์— ๋™์˜ํ•ด์ฃผ๊ณ  Finish ๋ˆŒ๋Ÿฌ์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.




์ขŒ์ธก ํ•˜๋‹จ์— ๋ณด๋ฉด ์„ค์น˜๊ฐ€ ์ง„ํ–‰๋˜๊ณ  ์žˆ๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
์‹œ๊ฐ„์ด ๋‹ค์†Œ ๊ฑธ๋ฆฝ๋‹ˆ๋‹ค.




์„ค์น˜๋ฅผ ์ง„ํ–‰ํ•˜๋‹ค ๋ณด๋ฉด ํ•ด๋‹น ํ™”๋ฉด์ด ๋‚˜ํƒ€๋‚  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Trust Authorities๋Š” Eclipse์™€ ๊ฐ™์€ IDE์—์„œ ํ”Œ๋Ÿฌ๊ทธ์ธ์ด๋‚˜ ์†Œํ”„ํŠธ์›จ์–ด๋ฅผ ์„ค์น˜ํ•  ๋•Œ ๋‚˜ํƒ€๋‚˜๋Š” ๋ณด์•ˆ ๊ด€๋ จ ์„ค์ •์ž…๋‹ˆ๋‹ค.

์ด ๊ณผ์ •์—์„œ ์„ค์น˜ํ•˜๋ ค๋Š” ์†Œํ”„ํŠธ์›จ์–ด๊ฐ€ ์‹ ๋ขฐํ•  ์ˆ˜ ์žˆ๋Š” ์ถœ์ฒ˜์—์„œ ์˜จ ๊ฒƒ์ธ์ง€๋ฅผ ํ™•์ธํ•˜๊ณ , ํ•ด๋‹น ์ถœ์ฒ˜(์ธ์ฆ ๊ธฐ๊ด€, CA)๋ฅผ ์‹ ๋ขฐํ• ์ง€๋ฅผ ๋ฌป๋Š” ์ ˆ์ฐจ์ž…๋‹ˆ๋‹ค.


์‹ ๋ขฐํ•  ์ˆ˜ ์žˆ๋Š” ์ถœ์ฒ˜์ผ ๊ฒฝ์šฐ

  • ๋ณดํ†ต ์ž˜ ์•Œ๋ ค์ง„ ํ”Œ๋Ÿฌ๊ทธ์ธ์ด๋‚˜ Eclipse ์ž์ฒด์˜ ๊ณต์‹ ํ”Œ๋Ÿฌ๊ทธ์ธ์ด๋ผ๋ฉด, ์ถœ์ฒ˜๊ฐ€ ์‹ ๋ขฐํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ Trust this certificate ๋˜๋Š” Accept๋ฅผ ์„ ํƒํ•˜๋Š” ๊ฒƒ์ด ์•ˆ์ „ํ•ฉ๋‹ˆ๋‹ค.

์ถœ์ฒ˜๊ฐ€ ๋ถˆ๋ช…ํ™•ํ•œ ๊ฒฝ์šฐ

  • ์ถœ์ฒ˜๊ฐ€ ํ™•์‹คํ•˜์ง€ ์•Š๊ฑฐ๋‚˜, ์˜์‹ฌ์Šค๋Ÿฌ์šด ์ธ์ฆ์„œ์ธ ๊ฒฝ์šฐ์—๋Š” Reject๋ฅผ ์„ ํƒํ•˜์—ฌ ์„ค์น˜๋ฅผ ์ค‘๋‹จํ•˜๋Š” ๊ฒƒ์ด ์ข‹์Šต๋‹ˆ๋‹ค.

์šฐ๋ฆฌ๊ฐ€ ์„ค์น˜ํ•˜๋Š” Spring Tools 4์™€ ๊ฐ™์€ ๊ณต์‹์ ์ธ ํ”Œ๋Ÿฌ๊ทธ์ธ์ด๋‚˜ Eclipse Marketplace์—์„œ ์ œ๊ณต๋˜๋Š” ๋„๊ตฌ๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ ์‹ ๋ขฐํ•  ์ˆ˜ ์žˆ๋Š” ์ธ์ฆ ๊ธฐ๊ด€์— ์˜ํ•ด ์„œ๋ช…๋ฉ๋‹ˆ๋‹ค.


๋”ฐ๋ผ์„œ Trust๋ฅผ ์„ ํƒํ•˜๊ณ  ๋„˜์–ด๊ฐ€๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.




๊ทธ ๋‹ค์Œ์œผ๋กœ ๋‚˜ํƒ€๋‚  ์ˆ˜ ์žˆ๋Š” ํ™”๋ฉด์ž…๋‹ˆ๋‹ค.


Trust Artifacts๋Š” ์†Œํ”„ํŠธ์›จ์–ด ์„ค์น˜๋‚˜ ๋ฐฐํฌ ์‹œ ๋‚˜ํƒ€๋‚˜๋Š” ๋ณด์•ˆ ๊ฐœ๋… ์ค‘ ํ•˜๋‚˜๋กœ, ์†Œํ”„ํŠธ์›จ์–ด ํŒจํ‚ค์ง€๋‚˜ ํ”Œ๋Ÿฌ๊ทธ์ธ(์ฆ‰, "artifacts")์ด ์‹ ๋ขฐํ•  ์ˆ˜ ์žˆ๋Š” ์ถœ์ฒ˜์—์„œ ์ œ๊ณต๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜๋Š” ๊ณผ์ •์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค.

์ด ์šฉ์–ด๋Š” ๋ณดํ†ต ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์ด๋‚˜ ํŒจํ‚ค์ง€ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ์—์„œ ์‚ฌ์šฉํ•˜๋Š”๋ฐ, ์†Œํ”„ํŠธ์›จ์–ด์˜ ๋ฌด๊ฒฐ์„ฑ๊ณผ ์ถœ์ฒ˜์˜ ์‹ ๋ขฐ์„ฑ์„ ๋ณด์žฅํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ํ™œ์šฉ๋ฉ๋‹ˆ๋‹ค.

์šฐ๋ฆฌ๋Š” Eclipse๋‚˜ Spring Tools์™€ ๊ฐ™์€ ๊ณต์‹ ๋ ฅ ์žˆ๋Š” ์ถœ์ฒ˜์—์„œ ๋‹ค์šด๋กœ๋“œํ•˜๊ธฐ ๋•Œ๋ฌธ์— artifacts๋Š” ์‹ ๋ขฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


๋”ฐ๋ผ์„œ ์ด๋ฒˆ์—๋„ Trust๋ฅผ ์„ ํƒํ•˜๊ณ  ๋„˜์–ด๊ฐ€๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.




์„ค์น˜๊ฐ€ ์™„๋ฃŒ๋˜๋ฉด ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์ ์šฉํ•˜๊ธฐ ์œ„ํ•ด eclipse๋ฅผ ์žฌ์‹œ์ž‘ ํ•  ๊ฒƒ์ด๋ƒ๋Š” ์•ˆ๋‚ด ๋ฉ”์„ธ์ง€๊ฐ€ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค.

์ง€๊ธˆ ๋‹ค์‹œ ์‹œ์ž‘์„ ๋ˆŒ๋Ÿฌ์„œ eclipse๋ฅผ ์žฌ์‹œ์ž‘ ํ•ด์ฃผ๋ฉด Spring Tools 4 ์„ค์น˜๊ฐ€ ์™„๋ฃŒ ๋ฉ๋‹ˆ๋‹ค.




1. Spring Starter Project ์ƒ์„ฑํ•˜๊ธฐ


eclipse๋ฅผ ์žฌ์‹œ์ž‘ํ•œ ํ›„, File -> New -> Other๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.




๊ฒ€์ƒ‰์ฐฝ์— Spring์„ ์ž…๋ ฅํ•˜๊ณ , Spring Starter Project๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.
Spring Starter Project๋ฅผ ์„ ํƒํ•˜๊ณ  Next๋ฅผ ํด๋ฆญํ•˜์—ฌ ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ ๊ณผ์ •์„ ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค.




ํ•„์š”ํ•œ ํ”„๋กœ์ ํŠธ ์„ค์ • ์ •๋ณด๋ฅผ ์ž…๋ ฅํ•˜๋Š” ํ™”๋ฉด์ด ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค.


Service URL: Spring Initializer ์„œ๋น„์Šค URL ์ž…๋‹ˆ๋‹ค.
Name: ํ”„๋กœ์ ํŠธ ์ด๋ฆ„ (์˜ˆ: demo)
Type: ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋นŒ๋“œ ํƒ€์ž…
Packaging: Packaging ํƒ€์ž…
Java Version: ์ž๋ฐ” ๋ฒ„์ „
Language: ์‚ฌ์šฉ ์–ธ์–ด
Group: ๊ทธ๋ฃน ์•„์ด๋””
Artifact: ์•„ํ‹ฐํŒฉํŠธ ์•„์ด๋””
Version: ๋ฒ„์ „ ์ •๋ณด
Description: ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„ค๋ช…
Package: ํŒจํ‚ค์ง€ ์ •๋ณด

์ฒ˜์Œ์—๋Š” ๊ธฐ๋ณธ ์„ค์ •๊ฐ’์ด ์žˆ์œผ๋ฏ€๋กœ ์ €๋Š” ๊ธฐ๋ณธ ์„ค์ •๊ฐ’์œผ๋กœ ์‚ฌ์šฉํ•˜๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.
์„ค์ •์„ ๋ฐ”๊พธ๊ณ  ์‹ถ์œผ๋ฉด ๋ฐ”๊ฟ”๋„ ๋ฌด๋ฐฉํ•ฉ๋‹ˆ๋‹ค.

์ž๋ฐ” ๋ฒ„์ „์€ ๋ช…๋ นํ”„๋กฌํ”„ํŠธ ์ฐฝ์—์„œ java -version์„ ์ž…๋ ฅํ•˜๋ฉด ๋‚˜์˜ต๋‹ˆ๋‹ค.
๋งŒ์•ฝ ๋‚˜์˜ค์ง€ ์•Š๊ฑฐ๋‚˜ ํ”„๋กœ์ ํŠธ ์„ค์ • ๋ชฉ๋ก์— ๋งž๋Š” ๋ฒ„์ „์ด ์—†๋‹ค๋ฉด Oracle ํ™ˆํŽ˜์ด์ง€์— ์ ‘์†ํ•˜์—ฌ JDK ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.


๐Ÿ’พ JDK ๋‹ค์šด๋กœ๋“œ โฌ…๏ธ ํด๋ฆญ


์„ค์ •์„ ๋งˆ์นœ ํ›„ Next๋ฅผ ํด๋ฆญํ•˜์—ฌ ๋‹ค์Œ์œผ๋กœ ๋„˜์–ด๊ฐ‘๋‹ˆ๋‹ค.




Spring Web์„ ์„ ํƒํ•˜์—ฌ Spring Boot ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๊ฐœ๋ฐœํ•  ์ˆ˜ ์žˆ๋„๋ก ์„ค์ •ํ•œ ํ›„ Finish๋ฅผ ๋ˆŒ๋Ÿฌ ๋งˆ๋ฌด๋ฆฌ ํ•ฉ๋‹ˆ๋‹ค.




2. Web Server ์‹คํ–‰ํ•˜๊ธฐ


ํ”„๋กœ์ ํŠธ๋ฅผ ์„ฑ๊ณต์ ์œผ๋กœ ๋งŒ๋“ค์—ˆ์œผ๋ฉด, ์ด์ œ ์›น์„œ๋ฒ„๋ฅผ ์‹คํ–‰ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.


๋จผ์ €, ์›น ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•  ์ปจํŠธ๋กค๋Ÿฌ๋ฅผ ์ƒ์„ฑํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.




์ขŒ์ธก์— ๋ณด์ด๋Š” ํ”„๋กœ์ ํŠธ ํด๋” ๋ชฉ๋ก์—์„œ src -> main -> java -> com.example.demo๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.




์œ„ ์ด๋ฏธ์ง€์— ๋ณด์ด๋Š” ๊ฒฝ๋กœ๋กœ ๋“ค์–ด๊ฐ€๋„ ๋ฌด๋ฐฉํ•ฉ๋‹ˆ๋‹ค.




์ด ํ›„ ์šฐํด๋ฆญ์„ ํ•œ ๋‹ค์Œ์— New -> Class๋ฅผ ํด๋ฆญํ•ด์ค๋‹ˆ๋‹ค.




๊ทธ๋Ÿฌ๋ฉด ์ƒ์„ฑํ•  ํด๋ž˜์Šค์˜ ์˜ต์…˜์„ ์„ค์ •ํ•˜๋Š” ํ™”๋ฉด์ด ๋‚˜์˜ค๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

์ €๋Š” ๋‹ค๋ฅธ ๋ถ€๋ถ„์€ ๊ฑด๋“œ๋ฆฌ์ง€ ์•Š๊ณ  ํŒŒ์ผ ์ด๋ฆ„๋งŒ HelloController๋กœ ์ž‘์„ฑํ•ด์ค€ ๋’ค Finish ๋ฒ„ํŠผ์„ ๋ˆŒ๋Ÿฌ ์™„๋ฃŒํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.





package com.example.demo;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
	//๊ธฐ๋ณธ ๊ฒฝ๋กœ
    @GetMapping("/")
    public String hello() {
    	//์›น์„œ๋ฒ„ ์‹คํ–‰์‹œ ํŽ˜์ด์ง€์— ๋‚˜ํƒ€๋‚  ๋ฌธ๊ตฌ
        return "Hello, Spring Boot!";
    }
}

์ดํ›„์—” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•ด์ฃผ๊ณ  ์ €์žฅํ•ด์ฃผ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.


๊ทธ ๋‹ค์Œ์—” ํด๋”์—์„œ DemoApplication.java ํŒŒ์ผ์„ ์šฐํด๋ฆญ ํ•œ ๋‹ค์Œ์— Run As -> Spring Boot App์„ ํด๋ฆญํ•˜์—ฌ ์„œ๋ฒ„๋ฅผ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ๋‹จ๊ณ„์—์„œ ํ”„๋กœ์ ํŠธ ๋ช…์„ ์ €์™€ ๋‹ค๋ฅธ ์ด๋ฆ„์œผ๋กœ ์„ค์ •ํ•˜์˜€๋‹ค๋ฉด, ํŒŒ์ผ ์ด๋ฆ„์ด ๋‹ค๋ฅผ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ ์งํ›„ src -> main -> java -> com.example.demo ๊ฒฝ๋กœ์— ์žˆ๋˜ ์ฒซ ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.


package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}

}

์œ„ ์ฝ”๋“œ์™€ ๋น„์Šทํ•œ ๋‚ด์šฉ์œผ๋กœ ์ž‘์„ฑ๋˜์–ด ์žˆ์„ ๊ฒƒ ์ž…๋‹ˆ๋‹ค.


๐ŸŽ‰ ์ด์ œ ๋งˆ์ง€๋ง‰ ์ž…๋‹ˆ๋‹ค!




์›น ๋ธŒ๋ผ์šฐ์ €์—์„œ URL ๊ฒ€์ƒ‰ ์ฐฝ์— http://localhost:8080 ์„ ์ž…๋ ฅํ•œ ํ›„ Hello, Spring Boot! ๋ฉ”์„ธ์ง€๊ฐ€ ์ถœ๋ ฅ์ด ๋œ๋‹ค๋ฉด, ์„ฑ๊ณต์ ์œผ๋กœ ์›น์„œ๋ฒ„๋ฅผ ์‹คํ–‰์‹œํ‚จ ๊ฒƒ ์ž…๋‹ˆ๋‹ค.




3. ์—๋Ÿฌ ํ•ด๊ฒฐ


ํฌ์ŠคํŒ…์„ ๋”ฐ๋ผ์„œ ์›น์„œ๋ฒ„๋ฅผ ์‹คํ–‰์‹œํ‚ค๋‹ค ๋ณด๋ฉด ๋งˆ์ฃผ์น  ์ˆ˜ ์žˆ๋Š” ์—๋Ÿฌ๊ฐ€ ๊ฐ„ํ˜น ์žˆ์Šต๋‹ˆ๋‹ค.


1. problem occurred

import getting started ontent has encounted a problem
toolchaindownloadFailedexception: no installed toolchains match and toolchain download repostrories have not been configured.


์—๋Ÿฌ ๋ฉ”์„ธ์ง€๋ฅผ ์‚ดํŽด๋ณด๋ฉด Eclipse๋‚˜ Maven์—์„œ Toolchain ๊ด€๋ จ ์„ค์ •์ด ์ œ๋Œ€๋กœ ๋˜์–ด ์žˆ์ง€ ์•Š์•„์„œ ๋ฐœ์ƒํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ํŠนํžˆ, Maven์ด๋‚˜ Gradle ๊ฐ™์€ ๋นŒ๋“œ ๋„๊ตฌ๊ฐ€ ํŠน์ • JDK ๋˜๋Š” Toolchain์„ ์ฐพ์ง€ ๋ชปํ•  ๋•Œ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๋ฌธ์ œ๋Š” ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•  ๋•Œ ํ•„์š”ํ•œ JDK ๋˜๋Š” ํŠน์ • ๊ฐœ๋ฐœ ๋„๊ตฌ๊ฐ€ ์„ค์น˜๋˜์ง€ ์•Š์•˜๊ฑฐ๋‚˜, ๋‹ค์šด๋กœ๋“œ ์„ค์ •์ด ๋˜์–ด ์žˆ์ง€ ์•Š์•„์„œ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.


๋Œ€๋ถ€๋ถ„์€ JDK ๋ฒ„์ „์ด ๋งž์ง€ ์•Š์•„์„œ ๊ทธ๋Ÿฐ ๊ฒƒ ์ž…๋‹ˆ๋‹ค.




๋„ค๋ชจ ๋ฐ•์Šค๊ฐ€ ๊ฐ€๋ฅดํ‚ค๋Š” ๋ถ€๋ถ„์„ ํ™•์ธํ•œ ํ›„ ์ˆซ์ž์— ๋งž๋Š” ๋ฒ„์ „์œผ๋กœ ์„ค์น˜ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.




2. ToolchainDownloadFailedException


ToolchainDownloadFailedException: No locally installed toolchains match and toolchain download repositories have not been configured.
java.lang.reflect.InvocationTargetException


์ด ์—๋Ÿฌ๋„ ๋Œ€๋ถ€๋ถ„ JDK ๋ฒ„์ „์œผ๋กœ ์ธํ•ด ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.
์„ค์ •์— ๋งž๋Š” JDK๋ฅผ ์„ค์น˜ํ•ด์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.


3. ์˜์กด์„ฑ ์—๋Ÿฌ


import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

ํ˜น์‹œ๋ผ๋„ Java ์ฝ”๋“œ ์ค‘ ํ•ด๋‹น ๋ถ€๋ถ„์—์„œ ์—๋Ÿฌ๊ฐ€ ๋ฐœ๊ฒฌ๋˜์—ˆ๋‹ค๋ฉด, Spring Web ๊ด€๋ จ ์˜์กด์„ฑ์ด ํ”„๋กœ์ ํŠธ์— ์ถ”๊ฐ€๋˜์ง€ ์•Š์•˜๊ฑฐ๋‚˜, Gradle์ด ์˜์กด์„ฑ์„ ์ œ๋Œ€๋กœ ๋‹ค์šด๋กœ๋“œํ•˜์ง€ ๋ชปํ•œ ๊ฒฝ์šฐ์ž…๋‹ˆ๋‹ค.




implementation 'org.springframework.boot:spring-boot-starter-web'


์ด ๊ฒฝ์šฐ ๋„ค๋ชจ ๋ฐ•์Šค๊ฐ€ ๊ฐ€๋ฅดํ‚ค๋Š” ์ฝ”๋“œ๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.




๐ŸŽ† ๋งˆ๋ฌด๋ฆฌ

์ด๊ฒƒ์œผ๋กœ Spring Framework๋ฅผ ํ™œ์šฉํ•œ ์›น์„œ๋ฒ„ ์‹คํ–‰ํ•˜๊ธฐ๋ฅผ ๋งˆ์น˜๊ฒ ์Šต๋‹ˆ๋‹ค.

์›น์„œ๋ฒ„๋ฅผ ํ™œ์šฉํ•˜์—ฌ ๋‹ค์–‘ํ•œ ์ฃผ์ œ์˜ ๊ฐœ๋ฐœ์„ ํ•˜๋ฉด์„œ, ์‹ค๋ ฅ์„ ๋”์šฑ ํ‚ค์›Œ ๋‚˜๊ฐ€์‹œ๊ธธ ๋ฐ”๋ž๋‹ˆ๋‹ค.

๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ๐Ÿ˜Œ

profile
Enjoy Develog!

0๊ฐœ์˜ ๋Œ“๊ธ€