๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Java·๏ปฟServlet·๏ปฟJSP

The import javax.servlet cannot be resolved ์—๋Ÿฌ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

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

๊นƒํ—ˆ๋ธŒ์—์„œ ๊ฐ„๋‹จํ•œ ์„œ๋ธ”๋ฆฟ ํ”„๋กœ์ ํŠธ๋ฅผ ์ž„ํฌํŠธํ–ˆ๋Š”๋ฐ ๋นŒ๋“œํ•˜๊ณ  ๋‚˜๋‹ˆ ์ด๋Ÿฐ ์—๋Ÿฌ๋“ค์ด ์ฐํžŒ๋‹ค.

 

The import javax.servlet cannot be resolved๋ฅผ ํฌํ•จํ•ด์„œ

GenericServlet cannot be resolved to a type

ServletException cannot be resolved to a type

ServletRequest cannot be resolved to a type

ServletResponse cannot be resolved to a type

WebServlet cannot be resolved to a type

 

๋ชจ๋‘ ์„œ๋ธ”๋ฆฟ ๊ด€๋ จ ์—๋Ÿฌ๋“ค์ด๋‹ค.

 

Java SE์—๋Š” ์„œ๋ธ”๋ฆฟ ํŒจํ‚ค์ง€๊ฐ€ ํฌํ•จ๋˜์–ด์žˆ์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

 

ํ”„๋กœ์ ํŠธ์˜ build path ์ฐฝ์— ๋“ค์–ด๊ฐ€๋ณด๋ฉด

Apache Tomcat v7.0์˜ Server Library๋ฅผ ํฌํ•จํ•˜๋Š”๋ฐ ํ˜„์žฌ ์ดํด๋ฆฝ์Šค์—๋Š” ํ†ฐ์บฃ7 ์„œ๋ฒ„๊ฐ€ ๋“ฑ๋ก๋˜์–ด ์žˆ์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— unbound๋ผ๊ณ  ํ‘œ์‹œ๋˜์–ด ์žˆ๋‹ค.

 

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์œผ๋กœ๋Š”..

 

1. ํ”„๋กœ์ ํŠธ์˜ Targeted Runtimes ์ •๋ณด๋ฅผ ๋ณ€๊ฒฝํ•œ๋‹ค.

ํ”„๋กœ์ ํŠธ์˜ ์ปจํ…์ŠคํŠธ ๋ฉ”๋‰ด์—์„œ Properties๋ฅผ ํด๋ฆญํ•œ๋‹ค.

 

Targeted Runtimes์—์„œ ํ˜„์žฌ ์ดํด๋ฆฝ์Šค์— ๋“ฑ๋ก๋˜์–ด์žˆ๋Š” ํ†ฐ์บฃ ์„œ๋ฒ„ ๋ฒ„์ „์œผ๋กœ ๋ณ€๊ฒฝํ•œ๋‹ค.

[Apply and Close]๋ฅผ ํด๋ฆญํ•˜์—ฌ ์ ์šฉํ•œ๋‹ค.

 

๋‹ค์‹œ ๋นŒ๋“œํ•˜๋ฉด ๋ณธ ์—๋Ÿฌ๋Š” ์‚ฌ๋ผ์ง„๋‹ค.

 

ํ”„๋กœ์ ํŠธ์˜ build path ์ฐฝ์„ ํ™•์ธํ•ด๋ณด๋ฉด, ์ž๋™์œผ๋กœ Apache Tomcat v9.0 ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ build path์— ์ถ”๊ฐ€๋์Œ์„ ์•Œ ์ˆ˜ ์žˆ๋‹ค.

 

๋ฐ˜์‘ํ˜•

 

2. ํ†ฐ์บฃ server runtime library ์ถ”๊ฐ€

์„œ๋ธ”๋ฆฟ ์ปจํ…Œ์ด๋„ˆ์ธ ํ†ฐ์บฃ์€ Java EE ์ŠคํŽ™์˜ ์ผ๋ถ€์ธ ์„œ๋ธ”๋ฆฟ์„ ์ง€์›ํ•˜๋ฉฐ servlet-api ๋ชจ๋“ˆ์„ ํฌํ•จํ•˜๊ณ  ์žˆ๋‹ค.

 

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

 

Server Runtime์„ ์„ ํƒํ•˜๊ณ  [Next >]๋ฅผ ํด๋ฆญํ•œ๋‹ค.

 

์—ฌ๊ธฐ์— ์ดํด๋ฆฝ์Šค์— ๋“ฑ๋ก๋œ ํ†ฐ์บฃ ์„œ๋ฒ„๊ฐ€ ํ‘œ์‹œ๋œ๋‹ค.

ํ†ฐ์บฃ ์„œ๋ฒ„๋ฅผ ์„ ํƒํ•˜๊ณ  [Finish]๋ฅผ ํด๋ฆญํ•œ๋‹ค.

 

ํŽผ์ณ๋ณด๋ฉด ํ†ฐ์บฃ์— ํฌํ•จ๋œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋“ค์ด build path์— ์ถ”๊ฐ€๋˜์—ˆ์Œ์„ ์•Œ์ˆ˜ ์žˆ๋‹ค.

์—ญ์‹œ [Apply and Close]๋ฅผ ํด๋ฆญํ•˜๊ณ  ๋‹ค์‹œ ๋นŒ๋“œํ•˜๋ฉด ํ•ด๋‹น ์—๋Ÿฌ๋Š” ์‚ฌ๋ผ์ง„๋‹ค.

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€