인프런 커뮤니티 질문&답변

성문님의 프로필 이미지
성문

작성한 질문수

스프링 MVC 1편 - 백엔드 웹 개발 핵심 기술

Hello 서블릿

httpservlet.java가 실행이 안되네요 ㅠ

작성

·

569

5

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'servletComponentRegisteringPostProcessor': Unexpected exception during bean creation; nested exception is java.lang.NoClassDefFoundError: javax/servlet/annotation/WebServlet

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:196) ~[spring-context-5.3.20.jar:5.3.20]

at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746) ~[spring-context-5.3.20.jar:5.3.20]

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564) ~[spring-context-5.3.20.jar:5.3.20]

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.0.jar:2.7.0]

at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.0.jar:2.7.0]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.0.jar:2.7.0]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.0.jar:2.7.0]

at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.0.jar:2.7.0]

at hello.servlet.ServletApplication.main(ServletApplication.java:12) ~[classes/:na]

Caused by: java.lang.NoClassDefFoundError: javax/servlet/annotation/WebServlet

at org.springframework.boot.web.servlet.WebServletHandler.<init>(WebServletHandler.java:39) ~[spring-boot-2.7.0.jar:2.7.0]

at org.springframework.boot.web.servlet.ServletComponentRegisteringPostProcessor.<clinit>(ServletComponentRegisteringPostProcessor.java:49) ~[spring-boot-2.7.0.jar:2.7.0]

at org.springframework.boot.web.servlet.ServletComponentScanRegistrar$ServletComponentRegisteringPostProcessorBeanDefinition.lambda$getInstanceSupplier$0(ServletComponentScanRegistrar.java:94) ~[spring-boot-2.7.0.jar:2.7.0]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1249) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1191) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.20.jar:5.3.20]

at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.20.jar:5.3.20]

... 13 common frames omitted

Caused by: java.lang.ClassNotFoundException: javax.servlet.annotation.WebServlet

at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[na:na]

at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]

at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]

... 20 common frames omitted

 

강의대로입력하였는데 다음과 같은 오류가 나오네요 

답변 4

8

성문님의 프로필 이미지
성문
질문자

run 실행 시 IntelliJ IDEA로 설정을 바꿨던 것을 Gradle 으로 다시 바꾸고 인텔리제이를 재시작하니 톰캣서버가 뜨고 해결되었습니다. 이방법으로 해결했네요 같은오류나오는분들은 수정해주세요 

0

와... 진짜 개고생하다 gradle로 바꾸니깐 실행이 잘 되네요...

0

감사합니다 gradle로 바꾸니 잘 되네요 그런데 계속 gradle로 해야하나봐요? intellij로 바꾸면 또 안되네요

0

동일한 오류로 프로젝트를 재생성하기도 했었는데,
오류 해결 방법 공유 감사합니다!

성문님의 프로필 이미지
성문

작성한 질문수

질문하기