Spring

Spring (Tomcat 서버)과 Maven으로 웹앱을 어떻게 만들 수 있습니까?

기록만이살길 2021. 3. 16. 03:08
반응형

Spring (Tomcat 서버)과 Maven으로 웹앱을 어떻게 만들 수 있습니까?

1. 질문(문제점):

내 응용 프로그램을 실행할 때 아래 콘솔 메시지가 표시되지만 http : // localhost : 8080 /? 다음과 같은 오류 메시지가 나타납니다.

"Whitelabel 오류 페이지이 응용 프로그램에는 / error에 대한 명시 적 매핑이 없으므로 대체 항목으로 간주됩니다.

Tue Jan 12 22:04:40 EST 2021 예기치 않은 오류가 발생했습니다 (유형 = 찾을 수 없음, 상태 = 404) "

콘솔 출력 :

2021-01-12 22:03:17.212  INFO 21710 --- [           main] com.crd.carrental.CarRentalApplication   : No active profile set, falling back to default profiles: default
2021-01-12 22:03:18.343  INFO 21710 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2021-01-12 22:03:18.350  INFO 21710 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-01-12 22:03:18.350  INFO 21710 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.39]
2021-01-12 22:03:18.424  INFO 21710 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-01-12 22:03:18.424  INFO 21710 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1073 ms
2021-01-12 22:03:18.539  INFO 21710 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'clientInboundChannelExecutor'
2021-01-12 22:03:18.542  INFO 21710 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'clientOutboundChannelExecutor'
2021-01-12 22:03:18.548  INFO 21710 --- [           main] o.s.s.c.ThreadPoolTaskScheduler          : Initializing ExecutorService 'messageBrokerTaskScheduler'
2021-01-12 22:03:18.613  INFO 21710 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'brokerChannelExecutor'
2021-01-12 22:03:19.539  INFO 21710 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2021-01-12 22:03:19.541  INFO 21710 --- [           main] o.s.m.s.b.SimpleBrokerMessageHandler     : Starting...
2021-01-12 22:03:19.541  INFO 21710 --- [           main] o.s.m.s.b.SimpleBrokerMessageHandler     : BrokerAvailabilityEvent[available=true, SimpleBrokerMessageHandler [DefaultSubscriptionRegistry[cache[0 destination(s)], registry[0 sessions]]]]
2021-01-12 22:03:19.541  INFO 21710 --- [           main] o.s.m.s.b.SimpleBrokerMessageHandler     : Started.
2021-01-12 22:03:19.551  INFO 21710 --- [           main] com.crd.carrental.CarRentalApplication   : Started CarRentalApplication in 2.977 seconds (JVM running for 5.797)
2021-01-12 22:04:18.616  INFO 21710 --- [MessageBroker-1] o.s.w.s.c.WebSocketMessageBrokerStats    : WebSocketSession[0 current WS(0)-HttpStream(0)-HttpPoll(0), 0 total, 0 closed abnormally (0 connect failure, 0 send limit, 0 transport error)], stompSubProtocol[processed CONNECT(0)-CONNECTED(0)-DISCONNECT(0)], stompBrokerRelay[null], inboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], outboundChannel[pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0], sockJsScheduler[pool size = 1, active threads = 1, queued tasks = 0, completed tasks = 0]
2021-01-12 22:04:23.920  INFO 21710 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2021-01-12 22:04:23.920  INFO 21710 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2021-01-12 22:04:23.929  INFO 21710 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 9 ms```

2. 해결방안:

Controller요청 된 URL에 "/"대해 아래와 같이 정의했는지 확인하십시오 .

@RequestMapping("/")
public String homePage() {
    ... <your code>
    return "home";
}

그리고 home페이지는 아래 경로에 저장되어야합니다.

|--resources
    |--templates
        |--home.html
65695175
반응형