안녕하세요.
안녕하세요, 먼저 정말 기다리던 강의를 드디어 볼 수 있게돼서 감사하다는 말씀을 드립니다!
강의를 따라가던 중 문제가 발생하여 조언을 구하고자 질문을 드립니다.
김영한 팀장님의 기존 인강에서는 [Settings] -> [Build Tools] -> [Gradle] 에서 Build and run using / Run tests using 모두 'IntelliJ IDEA'로 설정 후 강의를 진행하셔서 저도 그렇게 강의를 모두 수강했고 현재 혼자 개발 중인 서비스도 'IntelliJ IDEA' 로 설정해서 진행 중입니다.
이번 스프링 MVC 1편 인강에서는 섹션2 - 프로젝트 생성에서부터 Build and run using 을 'IntelliJ IDEA' 로 설정하면 다음과 같은 에러가 발생하고, Run tests Using 을 'GRADLE'로 설정하면 또 다음과 같은 에러가 발생합니다.
[Build and run using - 'IntelliJ IDEA' 설정 후 Application Run 한 상황 ]
2021-03-15 11:16:43.740 INFO 12576 --- [ main] travelbeeee.sec02.Sec02Application : Starting Sec02Application using Java 14.0.2 on DESKTOP-SJ3E1UQ with PID 12576 (C:\Users\HyunSeok\Desktop\studyWithMe\gitHub\studyWithMe\스프링MVC1편\sec02\out\production\classes started by HyunSeok in C:\Users\HyunSeok\Desktop\studyWithMe\gitHub\studyWithMe\스프링MVC1편\sec02)
2021-03-15 11:16:43.744 INFO 12576 --- [ main] travelbeeee.sec02.Sec02Application : No active profile set, falling back to default profiles: default
2021-03-15 11:16:44.376 WARN 12576 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: 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
2021-03-15 11:16:44.385 INFO 12576 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-03-15 11:16:44.406 ERROR 12576 --- [ main] o.s.boot.SpringApplication : Application run failed
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:537) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:196) ~[spring-context-5.3.4.jar:5.3.4]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:745) ~[spring-context-5.3.4.jar:5.3.4]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:563) ~[spring-context-5.3.4.jar:5.3.4]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767) ~[spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) ~[spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) ~[spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) ~[spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311) ~[spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) ~[spring-boot-2.4.3.jar:2.4.3]
at travelbeeee.sec02.Sec02Application.main(Sec02Application.java:13) ~[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.4.3.jar:2.4.3]
at org.springframework.boot.web.servlet.ServletComponentRegisteringPostProcessor.<clinit>(ServletComponentRegisteringPostProcessor.java:49) ~[spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.web.servlet.ServletComponentScanRegistrar$ServletComponentRegisteringPostProcessorBeanDefinition.lambda$getInstanceSupplier$0(ServletComponentScanRegistrar.java:94) ~[spring-boot-2.4.3.jar:2.4.3]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1231) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:564) ~[spring-beans-5.3.4.jar:5.3.4]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:524) ~[spring-beans-5.3.4.jar:5.3.4]
... 14 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.annotation.WebServlet
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602) ~[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:522) ~[na:na]
... 21 common frames omitted
Process finished with exit code 1
[ Run tests Using 을 Gradle로 설정 후 Test 를 빌드한 상황 ]
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :compileTestJava UP-TO-DATE
> Task :processTestResources NO-SOURCE
> Task :testClasses UP-TO-DATE
> Task :test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///C:/Users/HyunSeok/Desktop/studyWithMe/gitHub/studyWithMe/스프링MVC1편/sec02/build/reports/tests/test/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
4 actionable tasks: 1 executed, 3 up-to-date
설정을 아래 사진과 같이 바꿔주면 문제가 없어서 당장 수업을 듣는데는 지장이 없지만, 구글링을 해봐도 이유를 알아내기 어려워 조언을 구하고자 질문을 남깁니다.
답변 2
18
안녕하세요. 현석님
IntelliJ 무료 버전의 경우 해당 설정을 IntelliJ IDEA가 아니라 Gradle로 설정해야 합니다.
Jar 파일의 경우는 문제가 없는데, War의 경우 톰캣이 정상 시작되지 않는 문제가 발생할 수 있습니다.
유료 버전은 모두 정상 동작합니다.
또는 `build.gradle`에 있는 다음 코드를 제거해도 됩니다.
//`providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'`
메뉴얼을 최신버전으로 업데이트 했는데요. 관련 내용을 어제 포함해두었습니다^^
감사합니다.
1
저도 비슷한 문제가 있었는데, 영한쌤이 말씀해주신대로 providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' 을 지우고 나니 정상 실행이 되네요.
build.gradle 에서 위에 것을 지우고 나서 정상 실행이 되는 이유가 무엇인지 궁금합니다.
혹시 starter-web 에 tomcat 이 포함되어있는데 또 다른 tomcat 을 가져와 충돌로 인해 문제가 생겼던것인가요? 답변주시면 감사하겠습니다ㅎ
servlet과 container에 대한 질문입니다
0
16
1
api를 어느 컨트롤러에 작성해야하는지는 어떤 기준으로 해야하나요?
0
60
1
jsp 의존성 수정 요청
0
74
2
요즘 웹 서버가 주로 사용되는 이유는 SPA 구조 때문일까요 ?
0
142
1
save() 메서드 문의
0
65
1
절대 경로로 templates/basic 하위 파일 열면 css 적용 안되는 현상
0
99
1
request-body-json
0
83
2
MVC 패턴의 적용 단위
0
93
1
RequestMapping을 이용한 핸들러, 어댑터
0
118
2
save 후 결과화면
0
86
2
jsp를 이용한 view
0
97
1
application.properties에 debug 추가해도 결과가 똑같습니다.
0
172
1
수업 코드 제공 관련 문의
0
96
2
RequestMappingHandlerAdapter의 Controller 호출 과정
0
98
3
파일 오픈 시
0
68
1
스프링 배치 관련
0
77
1
@RequestParam의 defaultValue가 blank 값도 처리하는 지 여부
0
112
1
postman으로 /request-body-json-v1 호출시 500 error
0
93
1
프론트엔드와 백엔드의 mvc, rest api에 대한 질문
0
76
1
모델의 역할과 계층 분리에 대한 이해 차이 + 추가질문
0
111
1
console log 출력 관련 질문입니다.
0
73
1
애플리케이션이 실행 되지 않습니다 ㅠㅠㅠ
0
136
1
html 변경하는 부분 적용 문제
0
98
1
한글 깨짐
0
74
2





