๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Environment·Tool

[JAVA ์›น ๊ฐœ๋ฐœํ™˜๊ฒฝ] IntelliJ + Tomcat ์—ฐ๋™ ๋ฐฉ๋ฒ•

by Leica 2020. 1. 30.
๋ฐ˜์‘ํ˜•

์ด ํฌ์ŠคํŒ…์˜ ๋‚ด์šฉ์„ ๋ณด๊ฐ•ํ•ด์„œ IntelliJ๋กœ Java ์›น ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์„ ๊ตฌ์ถ•ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ๋” ์ž์„ธํžˆ ์ƒˆ๋กœ ์ž‘์„ฑํ–ˆ์Šต๋‹ˆ๋‹ค.

Maven ๋‚ด์šฉ์„ ์ถ”๊ฐ€ํ–ˆ์œผ๋ฏ€๋กœ ํ•ด๋‹น ๋‚ด์šฉ์ด ํ•„์š”ํ•˜์‹  ๋ถ„๋“ค์€ ์ƒˆ๋กœ ์ž‘์„ฑํ•œ ๊ธ€์„ ์ฐธ๊ณ ํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.

๐Ÿ”— IntelliJ JAVA ์›น ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ๊ตฌ์ถ• ๋ฐฉ๋ฒ• (+ Maven, Tomcat)


1. ํ†ฐ์บฃ(Tomcat) ์„œ๋ฒ„ ์„ค์น˜

์ž๋ฐ” ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ '์„œ๋ธ”๋ฆฟ'์ด๋ผ๊ณ  ๋ถ€๋ฅด๋ฉฐ ์„œ๋ธ”๋ฆฟ์„ ์‹คํ–‰ํ•˜๋ ค๋ฉด Java EE ๊ทœ์•ฝ์— ๋”ฐ๋ผ ๋งŒ๋“  '์„œ๋ธ”๋ฆฟ ์ปจํ…Œ์ด๋„ˆ'๊ฐ€ ํ•„์š”ํ•˜๋‹ค. ์•„ํŒŒ์น˜ ์†Œํ”„ํŠธ์›จ์–ด ์žฌ๋‹จ์—์„œ ์˜คํ”ˆ ์†Œ์Šค๋กœ ๋ฌด๋ฃŒ๋กœ ๋ฐฐํฌํ•˜๋Š” 'ํ†ฐ์บฃ(Tomcat)' ์„œ๋ฒ„๊ฐ€ ๋ฐ”๋กœ ์„œ๋ธ”๋ฆฟ ์ปจํ…Œ์ด๋„ˆ์ด๋‹ค.

 

https://tomcat.apache.org/

 

Apache Tomcat® - Welcome!

The Apache Tomcat® software is an open source implementation of the Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket technologies. The Java Servlet, JavaServer Pages, Java Expression Language and Java WebSocket specifications are

tomcat.apache.org

์œ„ ์‚ฌ์ดํŠธ์— ์ ‘์†ํ•ด์„œ Download - Tomcat 9๋ฅผ ํด๋ฆญํ•œ๋‹ค. (Tomcat 9๊ฐ€ Java 8์„ ์ง€์›ํ•œ๋‹ค.)

 

64๋น„ํŠธ ์œˆ๋„์šฐ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด 64-bit Windows zip์„ ํด๋ฆญํ•˜์—ฌ ๋‹ค์šด๋กœ๋“œ ๋ฐ›๋Š”๋‹ค.

 

์ฐธ๊ณ ๋กœ ๊ฐ€์žฅ ์œ„์˜ 'zip'์€ ์œˆ๋„์šฐ, ์œ ๋‹‰์Šค, ๋ฆฌ๋ˆ…์Šค์—์„œ ๋ชจ๋‘ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฐํฌํŒ์ด๋‹ค.

'32-bit Windows zip'์€ 32bit JVM์ด ์„ค์น˜๋œ PC์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฐํฌํŒ์ด๋‹ค.

๊ทธ ์™ธ '32-bit/64-bit Windows Service Installer'๋Š” ์„ค์น˜ํ˜• ๋ฐฐํฌํŒ์œผ๋กœ ๋ช…๋ น ํ”„๋กฌํ”„ํŠธ์—์„œ ํ†ฐ์บฃ์„ ์ œ์–ดํ•  ์ˆ˜ ์—†๊ณ  ์œˆ๋„์šฐ ์„œ๋น„์Šค์—์„œ๋งŒ ์ œ์–ดํ•  ์ˆ˜ ์žˆ๋‹ค.

 

์ ๋‹นํ•œ ๋””๋ ‰ํ† ๋ฆฌ์— ์••์ถ•์„ ํ‘ผ๋‹ค.

 

 

# ํ†ฐ์บฃ ์„œ๋ฒ„์˜ ์‹คํ–‰๊ณผ ์ ‘์† ํ…Œ์ŠคํŠธ

ํ†ฐ์บฃ ๋””๋ ‰ํ† ๋ฆฌ ํ•˜์œ„์˜ bin ํด๋” ์•ˆ์˜ startup.bat ํŒŒ์ผ์„ ์‹คํ–‰ํ•œ๋‹ค.

 

http://localhost:8080์— ์ ‘์†ํ•˜์—ฌ ์œ„ ๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด ์ถœ๋ ฅ๋˜๋ฉด ์ •์ƒ์ ์œผ๋กœ ํ†ฐ์บฃ์ด ์„ค์น˜, ์‹คํ–‰๋˜๊ณ  ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•œ๋‹ค.

 


2. IntelliJ ํ”„๋กœ์ ํŠธ์— Tomcat ์„œ๋ฒ„ ์ •๋ณด ๋“ฑ๋ก

- JAVA ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ๊ตฌ์ถ• - JDK, IntelliJ ์„ค์น˜ ๋ฐ ๊ธฐ๋ณธ ํ™˜๊ฒฝ ์„ค์ •

- IntelliJ IDEA - ๋ฌด๋ฃŒ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ต์œก ๋ผ์ด์„ผ์Šค ๋ฐ›๋Š” ๋ฐฉ๋ฒ•

 

1) ์ƒˆ ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ

์ƒˆ ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ•˜๊ธฐ ์œ„ํ•ด Create New Project๋ฅผ ํด๋ฆญํ•œ๋‹ค.

 

Project SDK์— ํ”„๋กœ์ ํŠธ์—์„œ ์‚ฌ์šฉํ•  JDK๋ฅผ ์„ ํƒํ•œ๋‹ค.

Web Application์„ ์ฒดํฌํ•œ๋‹ค.

WebServices๋ฅผ ์ฒดํฌํ•œ๋‹ค.

Version์„ Apache Axis๋กœ ์„ ํƒํ•œ๋‹ค.

 

[Next]๋ฅผ ํด๋ฆญํ•œ๋‹ค.

 

ํ”„๋กœ์ ํŠธ ์ด๋ฆ„๊ณผ ๊ฒฝ๋กœ๋ฅผ ์ž…๋ ฅํ•˜๊ณ  [Finish]๋ฅผ ํด๋ฆญํ•˜์—ฌ ์ƒˆ ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ์„ ๋งˆ์นœ๋‹ค.

 

 

2) ํ…Œ์ŠคํŠธ jsp ์ž‘์„ฑ

ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•ด index.jsp ํŒŒ์ผ์„ ์—ด์–ด ์ถœ๋ ฅํ•˜๊ณ ์ž ํ•˜๋Š” ๋‚ด์šฉ์„ ์ž…๋ ฅํ•œ๋‹ค. IntelliJ์—์„œ ํ†ฐ์บฃ์„ ์—ฐ๋™ ๋ฐ ๊ตฌ๋™ํ•˜์—ฌ ์ด ์›น ํ”„๋กœ์ ํŠธ๋ฅผ ์‹คํ–‰ํ•ด๋ณผ ๊ฒƒ์ด๋‹ค.

 

3) Tomcat ์„œ๋ฒ„ ์ •๋ณด ๋“ฑ๋ก

File - Settings๋ฅผ ํด๋ฆญํ•œ๋‹ค.

 

์ขŒ์ธก์—์„œ Build, Execution, Deployment - Application Servers ๋ฉ”๋‰ด๋ฅผ ์„ ํƒํ•˜๊ณ  [+]๋ฅผ ํด๋ฆญํ•œ๋‹ค.

Tomcat Server๋ฅผ ํด๋ฆญํ•œ๋‹ค.

 

Tomcat Home์˜ ์šฐ์ธก ๋””๋ ‰ํ† ๋ฆฌ ์•„์ด์ฝ˜์„ ํด๋ฆญํ•œ๋‹ค.

 

ํ†ฐ์บฃ์„ ์„ค์น˜ํ•œ ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ์„ ํƒํ•˜๊ณ  [OK]๋ฅผ ํด๋ฆญํ•œ๋‹ค.

 

์„ธ ๊ฐ€์ง€ ํ•ญ๋ชฉ์ด ์ž๋™์œผ๋กœ ์ž…๋ ฅ๋œ๋‹ค. [OK]๋ฅผ ํด๋ฆญํ•œ๋‹ค.

 

Application servers ๋ชฉ๋ก์— Tomcat 9๊ฐ€ ์ถ”๊ฐ€๋˜์—ˆ๋‹ค. [OK]๋ฅผ ํด๋ฆญํ•œ๋‹ค.

 

 

4) Run/Debug Configurations ์„ค์ •

Tomcat ์„œ๋ฒ„ ์ •๋ณด๋ฅผ IntelliJ์— ์ถ”๊ฐ€ํ–ˆ์œผ๋‹ˆ ์ด์ œ ์ด ํ”„๋กœ์ ํŠธ์— Run/Debug Configuration์„ ์„ค์ •ํ•  ์ฐจ๋ก€์ด๋‹ค.

 

์šฐ์ธก ์ƒ๋‹จ์˜ Add Configuration...์„ ํด๋ฆญํ•œ๋‹ค.

 

[+] - Tomcat Server - Local์„ ํด๋ฆญํ•œ๋‹ค.

๋ฆฌ์ŠคํŠธ์— ๋ณด์ด์ง€ ์•Š์„ ๊ฒฝ์šฐ more items(๋”๋ณด๊ธฐ)๋ฅผ ํด๋ฆญํ•˜์—ฌ ์ฐพ์•„๋ณธ๋‹ค.

 

Name ํ•ญ๋ชฉ์€ ์ด ์‹คํ–‰ ์„ค์ •์˜ ์ด๋ฆ„์ด๋‹ค. Application server๋ฅผ ์ด์ „์— Application servers์— ๋“ฑ๋กํ•œ Tomcat์œผ๋กœ ์„ค์ •ํ•œ๋‹ค.

์ฐธ๊ณ ๋กœ After launch ์šฐ์ธก์˜ ์„ค์ •(ํฌ๋กฌ ์•„์ด์ฝ˜)์„ ํ†ตํ•ด ์‹คํ–‰ ์‹œ ์‚ฌ์šฉํ•  ๋ธŒ๋ผ์šฐ์ €๋ฅผ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

 

ํ•˜๋‹จ์— Warning: No artifacts marked for deployment๋ผ๊ณ  ๋œจ๋Š”๊ฒƒ์ด ๋ณด์ธ๋‹ค.

์ด๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด Deployment ํƒญ์„ ํด๋ฆญํ•œ๋‹ค.

 

[+] - Artifact...๋ฅผ ํด๋ฆญํ•œ๋‹ค.

 

Application context๊ฐ€ ์ž๋™์œผ๋กœ ์ž…๋ ฅ๋œ๋‹ค. ํ…Œ์ŠคํŠธ ์šฉ์ด๋‹ˆ ๊ทธ๋ƒฅ ๋‘ฌ๋„ ๋˜๊ณ  ์›ํ•˜๋Š” ๊ฑธ๋กœ ๋ฐ”๊ฟ”๋„ ๋œ๋‹ค.

 

5) ์‹คํ–‰

๋งŒ๋“  ์›น ํ”„๋กœ์ ํŠธ๋ฅผ ์‹คํ–‰ํ•ด ๋ณธ๋‹ค.

 

๋ธŒ๋ผ์šฐ์ €์—์„œ ์ •์ƒ์ ์œผ๋กœ ๋ณด์—ฌ์ง„๋‹ค.

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€