Programming/Spring

IntelliJ | Spring MVC + Maven ํ”„๋กœ์ ํŠธ ๋งŒ๋“ค๊ธฐ (Oracle)

osean 2020. 7. 26. 02:18

๋“ค์–ด๊ฐ€๊ธฐ์— ์•ž์„œ


ํ˜„์žฌ ๊ตญ๋น„ ์ง€์› ํ•™์›์—์„œ ์ž๋ฐ”๋ฅผ ๊ณต๋ถ€ํ•˜๊ณ  ์žˆ๊ณ , ์„ธ๋ฏธ ํ”„๋กœ์ ํŠธ๋ฅผ ๋ง‰ ๋งˆ์นœ ์ƒํ™ฉ์ด๋‹ค.

์ด์ œ ์Šคํ”„๋ง ํ”„๋ ˆ์ž„ ์›Œํฌ๋ฅผ ๋ฐฐ์šฐ๋Š” ์ค‘์ธ๋ฐ, STS ๋ง๊ณ  ๋‹ค๋ฅธ IDE ๋กœ๋„ ๊ณต๋ถ€ํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„ ๋„์ „ํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค.

์ฒ˜์Œ IntelliJ ๋ฅผ ์ ‘ํ–ˆ์„ ๋•Œ Eclipse ์™€๋Š” UI ๋ผ๋˜์ง€ ์ฒ˜์Œ ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ค์–ด ๋‚ด๋Š” ๊ณผ์ •์ด ๋‹ฌ๋ผ ๋งŽ์ด ํ—ค๋งธ๊ณ , ์‚ฌ๋žŒ๋งˆ๋‹ค ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ๋‹ฌ๋ผ ์ •๋ณด ์œ ๋ชฉ๋ฏผ ์ƒํ™œ์ด ์กฐ๊ธˆ ๊ธธ์–ด์กŒ๋‹ค.

 

๊ทธ๋ž˜์„œ ๋‚ด๊ฐ€ ์–ด๋–ป๊ฒŒ ์Šคํ”„๋ง MVC + Maven ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ค์—ˆ๋Š”์ง€ ๊ธฐ๋ก ํ•  ๊ฒธ, ๋‚˜ ๊ฐ™์ด ์™„์ „ ์ดˆ๋ณด์ž๊ฐ€ ์ •๋ณด ์œ ๋ชฉ๋ฏผ ์ƒํ™œ์„ ์ฒญ์‚ฐํ•  ์ˆ˜ ์žˆ๊ฒŒ ์•„์ฃผ ์ž‘๊ฒŒ๋‚˜๋งˆ ๋„์›€์ด ๋  ๊ฒธ ํ•ด์„œ ๊ธ€์„ ์ ์–ด๋ณด๋ ค๊ณ  ํ•œ๋‹ค.

 

 

 

์‹œ์ž‘ํ•˜๊ธฐ


๋‹ค๋“ค IntelliJ ๋Š” ์ž˜ ์„ค์น˜ํ–ˆ์„๊ฑฐ๋ผ๋Š” ๊ฐ€์ • ํ•˜์— ์ง„ํ–‰ํ•˜๋ ค๊ณ  ํ•œ๋‹ค.

์ฒ˜์Œ์— IntellJ ๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ™”๋ฉด์ด ๋‚˜์˜ฌ ๊ฒƒ์ด๋‹ค.

[๊ทธ๋ฆผ1-1 ์‹œ์ž‘ํ•˜๊ธฐ]

์—ฌ๊ธฐ์„œ ์ƒˆ๋กœ์šด ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•˜๊ธฐ ์ „์— ํ™•์ธํ•˜๊ณ  ๋„˜์–ด๊ฐ€์•ผ ํ•  ๊ฒƒ์ด ์žˆ๋‹ค.

๋‚˜๋Š” ์ฒ˜์Œ์— Spring MVC ํ”Œ๋Ÿฌ๊ทธ์ธ์ด ๋ณด์ด์ง€ ์•Š์•„ ์ดํ‹€ ์ •๋„๋Š” ๋ณ„์— ๋ณ„ ์ง“์„ ๋‹ค ํ•ด๋ดค๋˜ ๊ฒƒ ๊ฐ™๋‹ค.

 

1. ๋‚ด๊ฐ€ ์‚ฌ์šฉํ•  ํ”Œ๋Ÿฌ๊ทธ์ธ์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ

์šฐ๋ฆฌ๊ฐ€ ์‚ฌ์šฉํ•ด์•ผ ํ•  ํ”Œ๋Ÿฌ๊ทธ์ธ์€ 

1) Spring MVC

2) Maven

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

 

  • ์œ„์˜ ํ™”๋ฉด์—์„œ ์šฐ์ธก ํ•˜๋‹จ์— Configure ๋ผ๋Š” ๋ฉ”๋‰ด๋ฅผ ํด๋ฆญํ•œ๋‹ค.
  • Configure ๋ฉ”๋‰ด์—์„œ Plugins ๋ฉ”๋‰ด๋ฅผ ํด๋ฆญํ•œ๋‹ค. 

[๊ทธ๋ฆผ 1-2 Plugins]

  • ๊ฒ€์ƒ‰์ฐฝ์— Spring MVC / Maven ๋ฅผ ๊ฒ€์ƒ‰ํ•˜๊ณ  ํ•ด๋‹น ํ”Œ๋Ÿฌ๊ทธ์ธ์ด ์ฒดํฌ๊ฐ€ ๋˜์–ด์žˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค.

[๊ทธ๋ฆผ 1-3 Spring MVC / Maven]

์œ„์˜ ๋‘ ์‚ฌํ•ญ์— ์ฒดํฌ๊ฐ€ ๋˜์—ˆ๋Š”์ง€ ํ™•์ธ์ด ๋˜์—ˆ๋‹ค๋ฉด ์ด์ œ ๋ณธ๊ฒฉ์ ์œผ๋กœ ์‚ฌ์šฉํ•  ์ค€๋น„๊ฐ€ ๋˜์—ˆ๋‹ค๋Š” ๋œป์ด๋‹ค.

 

2. ํ”„๋กœ์ ํŠธ ์ƒ์„ฑํ•˜๊ธฐ

  • ์ฒ˜์Œ ํ™”๋ฉด์˜ ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ ๋ฉ”๋‰ด๋ฅผ ํด๋ฆฐ๋‹จ๋‹ค.
  • ์ขŒ์ธก์˜ ํ”Œ๋Ÿฌ๊ทธ์ธ ์„ ํƒ ๋ฉ”๋‰ด์—์„œ Maven ์„ ์„ ํƒํ•œ๋‹ค.
  • ์ƒ๋‹จ์—์„œ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•˜๋Š” Java ์˜ JDK ๋ฒ„์ „์„ ์„ ํƒํ•œ๋‹ค. (์ €๋Š” 11๋กœ ์‚ฌ์šฉํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.)
  • Next ๋ฅผ ๋ˆ„๋ฅธ ํ›„ ํ”„๋กœ์ ํŠธ๋ช…์„ ์„ค์ •ํ•œ๋‹ค. (์—ฌ๊ธฐ์„œ ํ”„๋กœ์ ํŠธ๋ช…์€ artifactId ์™€ ๋™์ผํ•˜๊ฒŒ ์„ค์ •๋œ๋‹ค.)
  • ํ”„๋กœ์ ํŠธ๋ช… ์„ค์ • ํŽ˜์ด์ง€์—์„œ Artifact Coordinates ๋ฅผ ํด๋ฆญํ•˜์—ฌ GroupId ๋„ ์ž์‹ ์ด ์›ํ•˜๋Š”๋Œ€๋กœ ์„ค์ •ํ•œ๋‹ค.
    • GroupId ๋Š” ๋„๋ฉ”์ธ์˜ ์—ญ์ˆœ์œผ๋กœ ์ž‘์„ฑํ•œ๋‹ค.

[๊ทธ๋ฆผ 2-1 Maven ํ”Œ๋Ÿฌ๊ทธ์ธ ์„ ํƒํ•˜๊ธฐ]
[๊ทธ๋ฆผ 2-2 ํ•ด๋‹น ํ”„๋กœ์ ํŠธ๋ช…๊ณผ GroupId ์„ค์ •ํ•˜๊ธฐ]

์ผ๋‹จ Maven ๊ธฐ๋ฐ˜์˜ ํ”„๋กœ์ ํŠธ๋Š” ๋งŒ๋“ค์–ด์กŒ๋‹ค. ์ด์ œ ์šฐ๋ฆฌ๋Š” ์ด ํ”„๋กœ์ ํŠธ์— Spring MVC ๋ฅผ ๋ฎ์–ด ์”Œ์šธ ์˜ˆ์ •์ด๋‹ค.

 

 

 

Spring MVC + TomCat Server ์ถ”๊ฐ€ํ•˜๊ธฐ


1.  Spring MVC ํ”„๋ ˆ์ž„์›Œํฌ ์ถ”๊ฐ€ํ•˜๊ธฐ

  • ์ขŒ์ธก ์ƒ๋‹จ์— ํ•ด๋‹น ํ”„๋กœ์ ํŠธ๋ฅผ ์˜ค๋ฅธ์ชฝ ํด๋ฆญํ•˜๊ณ  (๋งฅ์˜ ๊ฒฝ์šฐ ctrl + ํŠธ๋ž™ํŒจ๋“œ) Add Framework Support... ๋ฅผ ํด๋ฆญํ•œ๋‹ค.
  • ์ƒˆ๋กœ์šด ์ฐฝ์ด ๋œจ๋ฉด, ์ขŒ์ธก ๋ฉ”๋‰ด์—์„œ Spring > Spring MVC ๋ฅผ ์„ ํƒํ•œ๋‹ค.
    • IntellJ ์—์„œ๋Š” Spring ์ตœ์‹  ๋ฒ„์ „์ธ 5.2.3 RELEASE ๋ฅผ ์ง€์›ํ•˜๊ณ  ์žˆ๊ณ , ์šฐ๋ฆฌ๋„ ์ด ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜๊ธฐ๋กœ ํ•œ๋‹ค.
  • ์„ ํƒ์„ ํ–ˆ๋‹ค๋ฉด ํ•ด๋‹น ํ”„๋กœ์ ํŠธ์— Spring ์„ ๋‹ค์šด ๋ฐ›์„ ๊ฒƒ์ด๋‹ค.

[๊ทธ๋ฆผ 3-1 ํ”„๋กœ์ ํŠธ ํด๋ฆญ ํ›„ ํ”„๋ ˆ์ž„์›Œํฌ ์ถ”๊ฐ€ํ•˜๊ธฐ]

 

[๊ทธ๋ฆผ 3-2 Spring MVC ์ฐพ์•„ ์„ ํƒํ•˜๊ธฐ]
[๊ทธ๋ฆผ 3-3 Spring MVC ๋‹ค์šด ๋ฐ›๊ธฐ]

2. TomCat Server ์ถ”๊ฐ€ํ•˜๊ธฐ 

  • ์ƒ๋‹จ ์ค‘์•™์—์„œ ๋ง์น˜ ๋ชจ์–‘ ์˜†์— Add Configuration... ์„ ์„ ํƒํ•œ๋‹ค.
  • ์ขŒ์ธก ์ƒ๋‹จ์—์„œ ์„ ํด๋ฆญํ•˜๊ณ  TomCat Server > Local ์„ ๋”๋ธ”ํด๋ฆญํ•˜์—ฌ ์„ ํƒํ•œ๋‹ค.
  • Port ๋ฒˆํ˜ธ๋ฅผ 9090 ์œผ๋กœ ๋ฐ”๊ฟ”์ค€๋‹ค.
    • ๋งฅ์˜ ๊ฒฝ์šฐ ๋„์ปค์™€ ํฌํŠธ๊ฐ€ ๊ฒน์น˜๋Š” ๊ฑธ ์˜ˆ๋ฐฉํ•˜๊ธฐ ์œ„ํ•ด์„œ ์ด๋ ‡๊ฒŒ ์„ค์ •ํ•œ๋‹ค.
      ์ €์˜ ๊ฒฝ์šฐ์—๋Š” ๋„์ปค ๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค ํฌํŠธ๊ฐ€ 8080์ด๋ผ ํ†ฐ์บฃ์„ 9090์œผ๋กœ ์„ค์ •ํ•ด์คฌ์Šต๋‹ˆ๋‹ค.
  • ํ•˜๋‹จ์— Fix ๋ฅผ ํด๋ฆญํ•˜๊ณ , ๊ฒฝ๋กœ๋ฅผ ์ž์‹ ์˜ ํ”„๋กœ์ ํŠธ๋ช…๊ณผ ๋˜‘๊ฐ™์ด ์ž…๋ ฅ ํ›„ 1)Apply 2)Ok ๋ฅผ ๋ˆŒ๋Ÿฌ์ค€๋‹ค.
    • ๋งŽ์€ ๊ฒŒ์‹œ๊ธ€์—์„œ ๊ฒฝ๋กœ๋ฅผ / ๋กœ ์„ค์ •ํ•ด์ฃผ๋ผ๊ณ  ํ•˜๋Š”๋ฐ, ์ฃผ์†Œ ์ž…๋ ฅํ•  ๋•Œ ํ—ท๊ฐˆ๋ฆฌ๊ธฐ๋„ ํ•˜๊ณ  ๋ฌด์—‡๋ณด๋‹ค ์ €๋Š” / ๋กœ ํ–ˆ์„ ๋•Œ ์•„๋ฌด๋ฆฌ ๋งž๋Š” ์ฃผ์†Œ๋ฅผ ์ž…๋ ฅํ•ด๋„ 404 ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•ด์„œ ํ•ด๋‹น ํ”„๋กœ์ ํŠธ ๋ช…์„ ์ž…๋ ฅํ–ˆ์Šต๋‹ˆ๋‹ค.

     

[๊ทธ๋ฆผ 4-1 ์ค‘์•™ ์ƒ๋‹จ์—์„œ ๋ง์น˜ ์•„์ด์ฝ˜์„ ์ฐพ์•„๋ผ]
[๊ทธ๋ฆผ 4-2 Templates ์—์„œ TomCat Server > Local ์ฐพ์•„ ์„ค์ •ํ•˜๊ธฐ]
[๊ทธ๋ฆผ 4-3 ํ•ด๋‹น ์„œ๋ฒ„์˜ Context ์„ค์ •ํ•˜๊ธฐ]

 

์ด์ œ ํ”„๋ ˆ์ž„์›Œํฌ์™€ ์„œ๋ฒ„ ์„ค์ •์„ ๋๋‚ฌ๋‹ค. ๋‹ค์Œ ๋‹จ๊ณ„์—์„œ๋Š” pom / web / dispatcher-servlet.xml ๋ฌธ์„œ๋“ค์„ ์†๋ด์ค„ ์˜ˆ์ •์ด๋‹ค.

 

 

 

xml ๋ฌธ์„œ๋“ค ํ˜ผ๋‚ด์ฃผ๊ธฐ


์œ„์˜ ๊ณผ์ •๋“ค์ด ์ž˜ ๋งˆ๋ฌด๋ฆฌ๊ฐ€ ๋˜์—ˆ๋‹ค๋ฉด 3๊ฐœ์˜ xml ๋ฌธ์„œ์— ํ•ด๋‹น ํ”„๋กœ์ ํŠธ๋ฅผ ์–ด๋–ป๊ฒŒ ์šด์˜ํ• ๊ฑด์ง€ ์„ ์–ธ(?) ํ•ด์ฃผ๋Š” ์ž‘์—…์„ ๊ฑฐ์ณ์•ผ ํ•œ๋‹ค.

 

1. pom.xml

  • ์œ„์˜ ๊ณผ์ •๋“ค์ด ๋๋‚˜๋ฉด ์ž๋™์œผ๋กœ pom.xml ํŒŒ์ผ์ด ์—ด๋ ค์žˆ์„ ๊ฒƒ์ด๋‹ค.
  • ํ•ด๋‹น xml ๋ฌธ์„œ์— ์•„๋ž˜์˜ ์ฝ”๋“œ๋ฅผ ๋ณต์‚ฌํ•ด์„œ ๋ถ™ํ˜€๋„ฃ์ž. ๊ทธ ์ „์— ๊ฐ์ž์˜ ํ™˜๊ฒฝ์ด ๋‹ค๋ฅด๋‹ˆ ํ™•์ธํ•ด์•ผ ํ•  ๊ฒƒ์ด ์žˆ๋‹ค.
    1. ์‚ฌ์šฉํ•  JDK ๋ฒ„์ „
    2. ์‚ฌ์šฉํ•  Spring ๋ฒ„์ „
    3. ์‚ฌ์šฉํ•  ๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค + ๋ฒ„์ „
  • ์ž์‹ ์ด ์–ด๋–ค ๋ฒ„์ „๋“ค์„ ์‚ฌ์šฉํ•  ๊ฒƒ์ธ์ง€ ํ™•์ธ ํ›„์— ์•„๋ž˜์˜ ์ฝ”๋“œ๋ฅผ ๋ณต์‚ฌํ•ด์„œ pom.xml์— ๋ณต์‚ฌ / ๋ถ™ํ˜€๋„ฃ๊ธฐ๋ฅผ ํ•˜์ž.
  • ์ด ์ฝ”๋“œ์—๋Š” ์˜ค๋ผํด ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ OJDBC 8 / DBCP ์— ๋Œ€ํ•œ ์ฝ”๋“œ๊ฐ€ ์žˆ์œผ๋‹ˆ ํ™•์ธํ•˜๊ณ  ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค. 
    ์ž์‹ ์—๊ฒŒ ๋งž๋Š” ๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค์˜ JDBC ์™€ DBCP ๋ฅผ Maven Repository ์—์„œ ์ฐพ์•„ ์ˆ˜์ •ํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.
  • ๋ถ™์—ฌ๋„ฃ์„ ๋•Œ ์ฃผ์˜์‚ฌํ•ญ
    • pom.xml ๋ฌธ์„œ ๋‚ด์— ์ฒ˜์Œ์— ์ž‘์„ฑ๋œ ์ฝ”๋“œ ๋‹ค์Œ์— ๋ถ™์—ฌ๋„ฃ๊ธฐ๋ฅผ ํ•ด์•ผํ•œ๋‹ค.
  • ์•„๋ž˜์˜ ์ฝ”๋“œ๋ฅผ ๋„ฃ์€ ๋‹ค์Œ ๋ฌธ์„œ์—์„œ ๋‚˜ํƒ€๋‚œ Maven ์•„์ด์ฝ˜์„ ํด๋ฆญํ•œ๋‹ค. ๊ทธ๋Ÿฌ๋ฉด ํ•ด๋‹น ๋ฌธ์„œ์— ๊ธฐ์ž…๋œ dependency ๋ฅผ ๋‹ค์šด๋ฐ›์•„ ์˜จ๋‹ค.

[๊ทธ๋ฆผ 5-1 pom.xml ๋ฌธ์„œ์— ์ฝ”๋“œ ๋„ฃ๊ธฐ]
[๊ทธ๋ฆผ 5-2 Maven ์•„์ด์ฝ˜ ํด๋ฆญํ•˜๊ณ  ํ•ด๋‹น ํ”„๋กœ์ ํŠธ์— Maven ์—…๋ฐ์ดํŠธ]

<!--
		์ด ๋ฌธ์„œ์—์„œ ์‚ฌ์šฉํ•  ๋ณ€์ˆ˜
	 --><properties>
    <java-version>11</java-version>
    <org.springframework-version>5.2.3.RELEASE</org.springframework-version>
    <org.aspectj-version>1.6.10</org.aspectj-version>
    <org.slf4j-version>1.6.6</org.slf4j-version>
</properties>

    <!-- ์˜์กด์„ฑ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ - ํ”„๋กœ์ ํŠธ์—์„œ ์‚ฌ์šฉํ•  ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์˜ ์ •๋ณด - groupId : ํšŒ์‚ฌ์ •๋ณด - artifactId : ํ”„๋กœ๊ทธ๋žจ์ •๋ณด
        - version : ๋ฒ„์ „์ •๋ณด -->
    <dependencies>
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework-version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>

        <!-- AspectJ -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${org.aspectj-version}</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${org.slf4j-version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
            <scope>runtime</scope>
        </dependency>

        <!-- @Inject -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>

        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>4.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>javax.servlet.jsp-api</artifactId>
            <version>2.3.3</version>
            <scope>provided</scope>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>

        <!-- OJDBC8 -->
        <dependency>
            <groupId>com.oracle.database.jdbc</groupId>
            <artifactId>ojdbc8</artifactId>
            <version>19.7.0.0</version>
        </dependency>
        <!-- ์˜์กด์„ฑ ์„ค์ • -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>

        <!-- DBCP -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-dbcp2</artifactId>
            <version>2.7.0</version>
        </dependency>

    </dependencies>

    <!-- ์‹ค์ œ ๋ช…๋ น ์ˆ˜ํ–‰ ์‹œ ํ•„์š”ํ•œ ์„ค์ • -->
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <mainClass>org.test.int1.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>

 

 

2. web.xml

web.xml ์—์„œ๋Š” ์ธ์ฝ”๋”ฉ ๋ฐฉ์‹, dispatcher ์„œ๋ธ”๋ฆฟ์— ๋Œ€ํ•œ ์„ค์ •์„ ์ง„ํ–‰ํ•œ๋‹ค.

  • WEB-INF > web.xml ํŒŒ์ผ์„ ์ฐพ๋Š”๋‹ค.
  • web-app ํƒœ๊ทธ ๋‚ด์— ์žˆ๋Š” ์ฝ”๋“œ๋“ค์„ ์ง€์šฐ๊ณ  ์•„๋ž˜์˜ ์ฝ”๋“œ๋ฅผ ๋ณต์‚ฌ ํ›„ ๋ถ™์—ฌ๋„ฃ๊ธฐ ํ•œ๋‹ค.

[๊ทธ๋ฆผ 6-1 web.xml ์— ์ฝ”๋“œ ๋ถ™์—ฌ๋„ฃ๊ธฐ]

    <!-- ์Šคํ”„๋ง์—์„œ ์ œ๊ณตํ•ด์ฃผ๋Š” ์ธ์ฝ”๋”ฉ ํ•„ํ„ฐ๋ฅผ ๋“ฑ๋ก -org.springframework.web.filter.CharacterEncodingFilter -->
    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>
            org.springframework.web.filter.CharacterEncodingFilter
        </filter-class>
        <!-- 1. ์ธ์ฝ”๋”ฉ ๋ฐฉ์‹์„ UTF-8 ๋ฐฉ์‹์œผ๋กœ ์„ค์ • -->
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <!-- 2. ์ถฉ๋Œ ์‹œ ๊ฐ•์ œ ์ธ์ฝ”๋”ฉ ์„ค์ • -->
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <!-- The definition of the Root Spring Container shared by all Servlets
        and Filters -->
    <!-- ๋ชจ๋“  ์„œ๋ธ”๋ฆฟ ๋ฐ ํ•„ํ„ฐ๊ฐ€ ๊ณต์œ ํ•˜๋Š” ๋ฃจํŠธ ์Šคํ”„๋ง ์ปจํ…Œ์ด๋„ˆ์˜ ์ •์˜ (์ตœ์ƒ์œ„ ์„ค์ • ํŒŒ์ผ) -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>

    <!-- Creates the Spring Container shared by all Servlets and Filters -->
    <!-- ๋ชจ๋“  ์„œ๋ธ”๋ฆฟ ๋ฐ ํ•„ํ„ฐ๊ฐ€ ๊ณต์œ ํ•˜๋Š” ์Šคํ”„๋ง ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค. (์„ค์ •์„ ์—ฐ๊ฒฐํ•ด์ฃผ๋Š” ๋„๊ตฌ๋ฅผ ๋“ฑ๋ก) -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>

    <!-- Processes application requests -->
    <!-- ์‘์šฉ ํ”„๋กœ๊ทธ๋žจ ์š”์ฒญ ์ฒ˜๋ฆฌ (์š”์ฒญ ์ฒ˜๋ฆฌ ๋ฉ”์ธ ์„œ๋ธ”๋ฆฟ ๋“ฑ๋ก > DispatcherServlet) -->
    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <!-- ์ถ”๊ฐ€ ์„ค์ •์— ๊ด€ํ•œ ๋‚ด์šฉ์„ ๋“ฑ๋ก -->
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/dispatcher-servlet.xml
            </param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

 

 

 

 

3. dispatcher-servlet.xml

ํ•ด๋‹น xml ์—์„œ๋Š” pom.xml ์—์„œ ๋“ฑ๋กํ–ˆ๋˜ JDBC / DBCP ๋ฅผ ๋“ฑ๋กํ•˜๋Š” ๊ณผ์ •์ด๋‹ค

  • WEB-INF > dispatcher-servlet.xml ์„ ์ฐพ์•„ ํŒŒ์ผ์„ ์—ฐ๋‹ค.
  • xml ๋‚ด์— ๋ชจ๋“  ์ฝ”๋“œ๋ฅผ ์ง€์šฐ๊ณ  ์•„๋ž˜์˜ ์ฝ”๋“œ๋ฅผ ๋ณต์‚ฌ ํ›„ ๋ถ™์—ฌ ๋„ฃ๋Š”๋‹ค.
  • ์•„๋ž˜์—์„œ <context:component-scan base-package="์ž์‹ ์ด ์„ค์ •ํ•œ GroupId.ArtifactId" /> ๋ฅผ ์ฐพ์•„ ์ˆ˜์ •ํ•œ๋‹ค.
    • ํ˜„์žฌ์— ์ž์‹ ์ด ์„ค์ •ํ•œ ๋Œ€๋กœ ์ž‘์„ฑํ•˜๋ฉด ๋นจ๊ฐ›๊ฒŒ ๋ณ€ํ• ํ…๋ฐ, ์ด ๋ถ€๋ถ„์€ ๋‚˜์ค‘์— ํ•ด๊ฒฐํ•  ๊ฒƒ์ด๋‹ค.

[๊ทธ๋ฆผ 7-1 dispatcher-servlet.xml ์—์„œ context:component-scan ํƒœ๊ทธ ์ˆ˜์ •ํ•˜๊ธฐ]

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans
        xmlns="http://www.springframework.org/schema/mvc"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:beans="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd
		http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
		http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">

    <!-- DispatcherServlet Context: defines this servlet's request-processing
        infrastructure -->

    <!-- Enables the Spring MVC @Controller programming model -->
    <annotation-driven />

    <!-- Handles HTTP GET requests for /resources/** by efficiently serving
        up static resources in the ${webappRoot}/resources directory -->
    <resources mapping="/resources/**" location="/resources/" />

    <!-- Resolves views selected for rendering by @Controllers to .jsp resources
        in the /WEB-INF/views directory -->
    <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <beans:property name="prefix" value="/WEB-INF/views/" />
        <beans:property name="suffix" value=".jsp" />
    </beans:bean>

    <!--JDBC ๋“ฑ๋ก -->
    <beans:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <beans:property name="driverClassName" value="oracle.jdbc.OracleDriver"></beans:property>
        <beans:property name="url" value="jdbc:oracle:thin:@localhost:1521:XE"></beans:property>
        <beans:property name="username" value="C##DO"></beans:property>
        <beans:property name="password" value="C##DO"></beans:property>
    </beans:bean>

    <!-- DBCP ๋“ฑ๋ก -->
    <beans:bean id="dbcpSource" class="org.apache.commons.dbcp2.BasicDataSource">
        <beans:property name="driverClassName" value="oracle.jdbc.OracleDriver"></beans:property>
        <beans:property name="url" value="jdbc:oracle:thin:@localhost:1521:XE"></beans:property>
        <beans:property name="username" value="C##DO"></beans:property>
        <beans:property name="password" value="C##DO"></beans:property>

        <beans:property name="maxTotal" value="20"></beans:property>
        <beans:property name="maxIdle" value="10"></beans:property>
        <beans:property name="maxWaitMillis" value="3000"></beans:property>
    </beans:bean>

    <beans:bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
        <!-- Dependency Injection > ํ•„์š”ํ•œ ๋„๊ตฌ๋ฅผ ์ฃผ์ž…ํ•œ๋‹ค๋Š” ์˜๋ฏธ -->
        <beans:property name="dataSource" ref="dataSource"></beans:property>
    </beans:bean>
    <context:component-scan base-package="GroupId.ArtifactId" />



</beans:beans>

xml ์— ๋Œ€ํ•œ ๋ถ€๋ถ„์€ ๋ชจ๋‘ ๋๋‚ฌ๋‹ค. ์ถ”ํ›„์— ์ž์‹ ์ด ๋” ํ•„์š”ํ•œ๊ฒŒ ์žˆ๋‹ค๋ฉด ์ž…๋ง›์— ๋งž๊ฒŒ ์ˆ˜์ •ํ•˜๋ฉด ๋œ๋‹ค.

์ด์ œ ์„ค์ •ํ•œ xml ์„ ํ•ด๋‹น ํ”„๋กœ์ ํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ์ถ”๊ฐ€ํ•˜๋Š” ์ž‘์—…์ด ์žˆ๋‹ค.

 

 

 

xml ์— ๋Œ€ํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ Artifacts์— ์ถ”๊ฐ€ํ•˜๊ธฐ


์œ„์—์„œ ์„ค์ •ํ•œ ๋ชจ๋“  ๊ฒƒ๋“ค์„ ํ•ด๋‹น ํ”„๋กœ์ ํŠธ์˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ์ถ”๊ฐ€ํ•˜๋Š” ์ž‘์—…์ด ํ•„์š”ํ•˜๋‹ค.

  • command + ; ํ˜น์€ ์šฐ์ธก ์ƒ๋‹จ์— ์•„์ด์ฝ˜์„ ๋ˆŒ๋Ÿฌ Project Structure ์ฐฝ์„ ์—ฐ๋‹ค.
  • ์ขŒ์ธก ๋ฉ”๋‰ด์—์„œ Artifacts ๋ฉ”๋‰ด ํด๋ฆญํ•œ๋‹ค.
  • ํ™”๋ฉด์˜ ์šฐ์ธก(Available Elements)์—์„œ ์ž์‹ ์˜ ํ”„๋กœ์ ํŠธ๋ฅผ ๋”๋ธ” ํด๋ฆญํ•˜๋ฉด ์ž์‹ ์˜ ํ”„๋กœ์ ํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ๋„ฃ์–ด์•ผ ํ•  ๋ชฉ๋ก์ด ๋œฌ๋‹ค.
    • ์ด ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋“ค์„ ๋”๋ธ”ํด๋ฆญํ•˜์—ฌ WEB-INF > lib ์— ๋„ฃ์–ด์ฃผ๋„๋ก ํ•˜์ž.
  • ๋‹ค ๋„ฃ์–ด์ค€ ํ›„, 1) apply 2)ok ์ˆœ์œผ๋กœ ํด๋ฆญํ•œ๋‹ค.

[๊ทธ๋ฆผ 8-1 Project Structure ์•„์ด์ฝ˜]
[๊ทธ๋ฆผ 8-2 Artifacts ๋ฉ”๋‰ด์—์„œ Available Elements > ์ž์‹ ์˜ ํ”„๋กœ์ ํŠธ ๋”๋ธ”ํด๋ฆญ > ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋”๋ธ”ํด๋ฆญ]
[๊ทธ๋ฆผ 8-3 ์œ„์˜ ๊ณผ์ •์ด ๋๋‚˜๋ฉด lib ํด๋”์— ์ƒ๊ธฐ๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ชฉ๋ก]

์ด์ œ ๋Œ€๋ถ€๋ถ„์˜ ์„ค์ •์€ ๊ฑฐ์˜ ๋์ด ๋‚ฌ๋‹ค.

์•ž์œผ๋กœ main > java ํด๋”์— ํŒจํ‚ค์ง€๋ฅผ ๋งŒ๋“ค๊ณ  Servlet + JSP ๋ฅผ ๋งŒ๋“ค์–ด ์ •์ƒ์ ์œผ๋กœ ์‹คํ–‰์ด ๋˜๋Š”์ง€ ํ…Œ์ŠคํŠธ ํ•  ๊ฒƒ์ด๋‹ค.

 

 

 

Package + Servlet + JSP ๋งŒ๋“ค๊ธฐ


1. package + servlet ๋งŒ๋“ค๊ธฐ

์•ž์—์„œ ์ง„ํ–‰ํ•œ dispatcher-servlet.xml ์—์„œ <context:component-scan base-package="์ž์‹ ์ด ์„ค์ •ํ•œ GroupId.ArtifactId" /> ํƒœ๊ทธ๊ฐ€ ์˜ค๋ฅ˜๊ฐ€ ๋‚œ ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ, java ํด๋” ๋‚ด์— ์œ„์˜ ๊ฒฝ๋กœ๋Œ€๋กœ package ๋ฅผ ๋งŒ๋“ค๋ฉด ํ•ด๊ฒฐ์ด ๋œ๋‹ค.

  • src > main > java ํด๋”์— ์œ„์— ์ž‘์„ฑํ•œ ๊ฒฝ๋กœ๋Œ€๋กœ package ์ƒ์„ฑํ•œ๋‹ค.
  • ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด ๋งˆ์ง€๋ง‰ package ์— TestController ๋ฅผ ๋งŒ๋“ ๋‹ค.
  • TestController.java ์— ํ•ด๋‹น ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•œ๋‹ค.
    • ๋ถ™์—ฌ๋„ฃ์ง€ ๋งˆ์‹œ๊ณ  ์ง์ ‘ ์ž‘์„ฑํ•ด์„œ ๋„ฃ์–ด๋ณด์„ธ์š”.

[๊ทธ๋ฆผ 9-1 package ์ƒ์„ฑ ๋ฐฉ๋ฒ•]
[๊ทธ๋ฆผ 9-2 package ๊ฐฏ์ˆ˜์™€ ์ด๋ฆ„ > dispatcher-servlet.xml ์— ์„ค์ •ํ•œ ๊ฒฝ๋กœ๋Œ€๋กœ ์ƒ์„ฑ]
[๊ทธ๋ฆผ 9-3 ์ƒ์„ฑ๋œ package ๋งˆ์ง€๋ง‰์— TestController class ํŒŒ์ผ ๋งŒ๋“ค๊ธฐ]
[๊ทธ๋ฆผ 9-4 TestController ํŒŒ์ผ์— ์ž์‹ ์ด ์›ํ•˜๋Š” ์ฝ”๋“œ ์ž‘์„ฑ ํ›„ ์ €์žฅ]

 

 

 

2. WEB-INF > views > test.jsp ๋งŒ๋“ค๊ธฐ

ํ˜„์žฌ ์šฐ๋ฆฌ์˜ ํ”„๋กœ์ ํŠธ๋Š” dispatcher-servlet.xml ์—์„œ view ์— ๋Œ€ํ•œ ๋ถ€๋ถ„์„ WEB-INF.views ๋ถ€ํ„ฐ ์ ์šฉํ•ด๋†จ๋‹ค.

์ด ๋ถ€๋ถ„์€ ์ž์‹ ์˜ ์ž…๋ง›์— ๋”ฐ๋ผ ๋ณ€๊ฒฝ๊ฐ€๋Šฅํ•˜์ง€๋งŒ, ์šฐ๋ฆฌ๋Š” STS ์—์„œ ์ž๋™์œผ๋กœ ๋งŒ๋“ค์–ด์ง„ ํƒœ๊ทธ ๊ทธ๋Œ€๋กœ ๊ฐ€์ ธ๋‹ค ์“ด ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ์ผ๋‹จ์€ ํ…Œ์ŠคํŠธ ์šฉ์œผ๋กœ ์ง„ํ–‰ํ•ด๋ณด๋„๋ก ํ•˜์ž.

  • WEB-INF ํด๋” ์•ˆ์— views ํด๋”๋ฅผ ๋งŒ๋“ ๋‹ค.
  • views ํด๋” ์•ˆ์— ์ž์‹ ์ด ์œ„์—์„œ ๋ฆฌํ„ดํ•˜๊ณ ์ž ํ•˜๋Š” ๋ฌธ์ž์—ด์˜ jsp ํŒŒ์ผ์„ ๋งŒ๋“ ๋‹ค. (๋‚˜๋Š” test ๋ฅผ ๋ฆฌํ„ดํ•˜๋‹ˆ๊นŒ test.jsp ๋ฅผ ๋งŒ๋“ค ๊ฒƒ์ด๋‹ค.)

[๊ทธ๋ฆผ 10-1 WEB-INF > views ํด๋”๋ฅผ ๋งŒ๋“ค๊ณ , jsp ํŒŒ์ผ ์ƒ์„ฑํ•˜๊ธฐ]
[10-2 ์ƒ์„ฑํ•œ jsp ํŒŒ์ผ์— ํ…Œ์ŠคํŠธ ํ™•์ธ์„ ์œ„ํ•œ ๋ฌธ์ž์—ด ์ž‘์„ฑํ•˜๊ธฐ]

์ด์ œ ๋ชจ๋“  ์„ค์ •์€ ๋์ด ๋‚ฌ๋‹ค.

๋งˆ๋ฌด๋ฆฌ๋กœ๋Š” ์šฐ๋ฆฌ๊ฐ€ ์„ค์ •ํ•œ ๊ฒƒ์ด ์ž˜ ๊ตฌ๋™์ด ๋˜๋Š”์ง€ ํ…Œ์ŠคํŠธ ํ•ด๋ณด๋Š” ๊ฒƒ์ด๋‹ค.

 

 

 

ํ…Œ์ŠคํŠธ ํ•ด๋ณด๊ธฐ


 

์ด์ œ ์šฐ๋ฆฌ์˜ ๊ณผ์ •์ด ์ž˜ ์ ์šฉ์ด ๋˜์—ˆ๋Š”์ง€ ํ…Œ์ŠคํŠธ ํ•ด๋ณผ ์ผ๋งŒ ๋‚จ์•˜๋‹ค. ๊ธด์žฅ์ด ๋˜๋Š” ์ˆœ๊ฐ„์ด๋‹ค.

์šฐ๋ฆฌ๋Š” ํ…Œ์ŠคํŠธ์—์„œ jsp ํŒŒ์ผ์„ ์ง์ ‘ ๊ตฌ๋™์‹œํ‚ค๋Š”๊ฒŒ ์•„๋‹ˆ๋ผ tomcat ์„ ๊ตฌ๋™์‹œํ‚ฌ ๊ฒƒ์ด๋‹ค.

  • ๋งฅ > ctrl + option + r ๋‹จ์ถ•ํ‚ค๋ฅผ ๋ˆŒ๋Ÿฌ TomCat > Run
  • ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์‹คํ–‰๋˜๋ฉด index.jsp ํŒŒ์ผ์ด ์—ด๋ฆด ๊ฒƒ์ด๋‹ค.
  • ์ฃผ์†Œ์ฐฝ์— ์ž์‹ ์ด ์„ค์ •ํ•œ ์ปจํŠธ๋กค๋Ÿฌ ์ฃผ์†Œ(RequestMapping) + GetMapping ์— ์ง€์ •ํ•œ ์ฃผ์†Œ๋ฅผ ๋„ฃ๊ณ  ์ด๋™ํ•œ๋‹ค.
    • ์ €์™€ ๋˜‘๊ฐ™์ด ํ•˜์…จ๋‹ค๋ฉด ์•„๋ž˜์˜ ์ฃผ์†Œ๋กœ ์ด๋™ํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค. 
    • http://localhost:9090/testspring/test/go
  • ์ด๋™ ํ›„, ์ž์‹ ์ด ๋ฆฌํ„ดํ•˜๊ณ ์ž ํ•˜๋Š” jsp๊ฐ€ ์ œ๋Œ€๋กœ ์—ด๋ฆฌ๋ฉด ์„ฑ๊ณต์ด๋‹ค.

[๊ทธ๋ฆผ 11-1 TomCat Server ์‹คํ–‰]
[๊ทธ๋ฆผ 11-2 test.jsp ์‹คํ–‰ ์„ฑ๊ณต]

 

 

 

๋งˆ์น˜๋ฉฐ


๋‚˜๋Š” Spring MVC + Maven ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“œ๋Š” ๊ณผ์ •์„ ํ•™์›์—์„œ ์œˆ๋„์šฐ๋กœ ๋ฐฐ์› ๋‹ค.

๊ทธ๋ž˜์„œ ์œˆ๋„์šฐ์—์„œ ํ•ด๋‹น ํ”„๋กœ์ ํŠธ๋Š” ์ด์   ํ˜ผ์ž์„œ๋„ ๋„ˆ๋ฌด ์ž˜ ๋งŒ๋“ ๋‹ค.

 

ํ•˜์ง€๋งŒ IntelliJ ์—์„œ ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“œ๋Š” ๊ณผ์ •์ด STS ์™€ ์ •๋ง ๋งŽ์ด ๋‹ฌ๋ž๊ณ , ๋งŽ์€ ๋ธ”๋กœ๊ทธ์—์„œ ๋งํ•˜๋Š” ๋ฐฉ๋ฒ•๋“ค์ด (xml ์ด๋ผ๋˜์ง€) ์ œ ๊ฐ๊ฐ์ด๋ผ ์–ด๋–ค๊ฒŒ ๋งž๋Š”๊ฑด์ง€ ์•Œ ์ˆ˜๊ฐ€ ์—†์—ˆ๋‹ค. ๊ทธ๋ž˜์„œ ๊ฒฐ๊ตญ ๋ธ”๋กœ๊ทธ๋ฅผ ๋”ฐ๋ผํ•˜๊ธฐ ๋ณด๋‹จ ๋งŽ์€ ๊ธ€๋“ค์ด ๋งํ•˜๋Š” ๋ถ€๋ถ„๋งŒ์„ ์ œ์™ธํ•˜๊ณ  ํ•™์›์—์„œ ๋ฐฐ์šด๋Œ€๋กœ ํ•ด๋ณด๋ ค๊ณ  ํ•˜๋‚˜ ํ•˜๋‚˜ ๊ณผ์ •์„ ์ดํ•ดํ•˜๋ฉด์„œ ๋‚˜์•„๊ฐ€๋‹ˆ ๊ฒฐ๊ตญ์€ ์„ฑ๊ณตํ–ˆ๋‹ค.

 

์ด ๊ณผ์ •์—์„œ ๋‚˜๋Š” ์Šคํ”„๋ง์„ ๋ฐฐ์šด ์ฒซ ๋‚ ๋ถ€ํ„ฐ ์ง€๊ธˆ๊นŒ์ง€ ๋ฐค๋‚ฎ ์—†์ด ๊ณ„์† ๋„์ „ํ•ด์™”๋Š”๋ฐ, ๋‚ด๊ฐ€ ๊ทธ๋ ‡๊ฒŒ ๊ณ ์ƒํ•  ์ˆ˜ ๋ฐ–์— ์—†์—ˆ๋˜ ์ด์œ ๋Š”!

ํ”„๋กœ์ ํŠธ๊ฐ€ ๋งŒ๋“ค์–ด์ง€๋Š” ๊ณผ์ •์„ ์ „ํ˜€ ์ดํ•ดํ•˜์ง€ ๋ชปํ•˜๊ณ  ๊ทธ์ € ๋ธ”๋กœ๊ทธ์—์„œ ํ•˜๋ผ๋Š”๋Œ€๋กœ ๋”ฐ๋ผํ•˜๊ธฐ ๊ธ‰๊ธ‰ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ทผ๋ณธ์— ๋Œ€ํ•œ ์ดํ•ด์—†์ด ๋งŒ๋“ค๋ ค๊ณ  ํ•˜๋‹ค๋ณด๋‹ˆ ๊ณ„์† ์‹คํŒจํ–ˆ๋˜ ๊ฒƒ ๊ฐ™๋‹ค.

 

ํ•™์› ๋™๊ธฐ๋“ค์—๊ฒŒ๋„ ํ•ญ์ƒ '๊ฐ•์‚ฌ๋‹˜ ์ฝ”๋“œ ๋ฌด์กฐ๊ฑด ๋ณต์‚ฌ ๋ถ™์—ฌ๋„ฃ๊ธฐ ํ•˜์ง€ ๋ง๋ผ' ๊ณ  ๋งํ•˜๋Š” ๋‚ด๊ฐ€ ๊ทธ๋ ‡๊ฒŒ ํ–‰๋™ํ•˜๋‹ค๋‹ˆ ๋‚ด ์ž์‹ ์—๊ฒŒ ์ฐธ ๋ถ€๋„๋Ÿฝ๋‹ค.

 

์ด ๊ธ€์„ ์ฝ๋Š” ๋งŽ์€ ๋ถ„๋“ค์€ ๋‚˜์ฒ˜๋Ÿผ ๋ฌด์ž‘์ • ๋ณต์‚ฌ ๋ถ™์—ฌ๋„ฃ๊ธฐ๋Š” ํ•˜์ง€ ์•Š์•˜์œผ๋ฉด ์ข‹๊ฒ ๋‹ค.

์ดํ•ด๋˜์ง€ ์•Š๊ณ  ํ•˜๋Š” ๊ฒƒ๊ณผ ๋ฏธ์„ธํ•˜๊ฒŒ๋‚˜๋งˆ ์ดํ•ดํ•˜๊ณ  ํ•˜๋Š” ๊ฒƒ์€ ์™„์ „ ํ•˜๋Š˜๊ณผ ๋•… ์ฐจ์ด๋ผ๊ณ  ์ƒ๊ฐํ•œ๋‹ค. ์•ž์œผ๋กœ ๋‚˜์•„๊ฐ€๋Š” ์ •๋„๋„ ํ™•์—ฐํžˆ ์ฐจ์ด๊ฐ€ ๋‚˜๊ณ .

 

๋‘์„œ๋„ ์—†๊ณ  ์ž์„ธํ•˜์ง€๋„ ์•Š์€ ๊ธ€์„ ์ฝ์–ด์ฃผ์‹  ๋ชจ๋“  ๋ถ„๋“ค๊ป˜ ๊ฐ์‚ฌํ•˜๊ณ , ์ด๋ฒˆ ์‚ฌ๊ฑด(?) ์„ ๊ณ„๊ธฐ๋กœ ์ฐจ๊ทผ์ฐจ๊ทผ ๋‚˜์•„๊ฐ€๋ ค๊ณ  ๋…ธ๋ ฅํ•ด์•ผ๊ฒ ๋‹ค. 

'Programming > Spring' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[QueryDSL] NoSuchMethodError Trouble Shooting  (0) 2023.02.22
Criteria API  (0) 2023.01.28
Spring Bean / IoC Container / DI  (1) 2023.01.21
JPA / Persistence Context / Transactional  (2) 2023.01.14
Spring | Spring Framework ?  (0) 2020.08.02