-
카테고리
-
세부 분야
백엔드
-
해결 여부
미해결
강의 초반에 나오는 코드에서 에러가 납니다.
23.04.09 22:43 작성 조회수 417
0
0:05초 부분에서 applicationContext를 익명클래스가 아닌 람다 표현식으로 바뀌어져있는데, 이 부분을 그대로 따라 쳤는데, 에러가 납니다.
public static void main(String[] args) {
AnnotationConfigWebApplicationContext applicationContext = onRefresh() -> {
super.onRefresh();
ServletWebServerFactory serverFactory = this.getBean(ServletWebServerFactory.class);
DispatcherServlet dispatcherServlet = this.getBean(DispatcherServlet.class);
WebServer webServer = serverFactory.getWebServer(servletContext -> {
servletContext.addServlet("dispatcherServlet", dispatcherServlet)
.addMapping("/*");
});
webServer.start();
};
applicationContext.register(HellobootApplication.class); // 구성정보가 있는 클래스 등록
applicationContext.refresh();
}
}
onRefresh() -> {
...
}
이 부분이 이해가 잘 되지 않는데, 어느 부분이 잘못된 건가요?
AnnotationConfigWebApplicationContext applicationContext = onRefresh() -> {
super.onRefresh();
답변을 작성해보세요.
0
토비
지식공유자2023.04.10
강의에 나오는 코드는 다음과 같습니다. 앞부분 코드를 잘못 작성하신 것 같습니다.
AnnotationConfigWebApplicationContext applicationContext =
new AnnotationConfigWebApplicationContext() {
@Override
protected void onRefresh() {
super.onRefresh();
답변 1