프로그래밍/Java

[SpringBoot] 나를 빡치게 하는 Hello World!

창수씨 2022. 10. 18. 01:05
반응형

미드저니에게 스프링을 설명해봤다.

https://start.spring.io/

이런식으로 체크해서 받았다. 데스크탑에는 자바1.8, 자바11 등이 깔려있다.
그리고 인텔리J를 켜서 demo 폴더를 오픈해버렸다.

  그리곤 인텔리제이의 실행에 들어가니 Alt + Shift + F10실행.... 이라는 버튼이 있었는데 눌렀더니 되어 버렸다. 하지만 나는 여전히 빡쳐있다. 왜냐? 어제는 안됐었거든. 다른 폴더는 안되었거든. 이게 도대체 뭔데 나를 이렇게 빡치게 만드는 것일까. 안될때마다 적을테다.

오전 12:48:11: 실행 중 ':DemoApplication.main()'...

> Task :compileJava
> Task :processResources
> Task :classes

> Task :DemoApplication.main()

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.7.4)

2022-10-18 00:48:14.545  INFO 9384 --- [           main] com.example.demo.DemoApplication         : Starting DemoApplication using Java 11.0.14 on DESKTOP-G with PID 9384 (D:\dev\spring_boot\demo\build\classes\java\main started by hanju in D:\dev\spring_boot\demo)
2022-10-18 00:48:14.549  INFO 9384 --- [           main] com.example.demo.DemoApplication         : No active profile set, falling back to 1 default profile: "default"
2022-10-18 00:48:15.849  INFO 9384 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2022-10-18 00:48:15.863  INFO 9384 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2022-10-18 00:48:15.863  INFO 9384 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.65]
2022-10-18 00:48:15.978  INFO 9384 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2022-10-18 00:48:15.979  INFO 9384 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1377 ms
2022-10-18 00:48:16.371  INFO 9384 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2022-10-18 00:48:16.382  INFO 9384 --- [           main] com.example.demo.DemoApplication         : Started DemoApplication in 2.286 seconds (JVM running for 2.754)
2022-10-18 00:48:36.579  INFO 9384 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2022-10-18 00:48:36.580  INFO 9384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2022-10-18 00:48:36.581  INFO 9384 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms

이러면서 localhost:8080 접속까지 가능했다. 아무것도 안뜨고 

오류페이지. 오류페이지가 떴을땐 제대로 부트가 실행된거임.

기왕 이렇게 된거 검색하면서 헬로월드도 찍어버렸다.

그래 안녕

추가되는 파일명은 com.example.demo 아래의 DemoController.java라고 만들어 줬다.

package com.example.demo;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {
    @GetMapping("/")
    public String helloWorld() {
        return "Hello, World";
    }
}

첫번째 빡치는 부분 1. 처음 소스를 인터넷에서 복사 붙여넣기 했을 때 오류가 났음.

심볼 'RestController'을 해결할수 없습니다
심볼 'GetMapping'을 해결할수 없습니다

이 따위 오류가 났는데, 손으로 하나하나 치다보니 인텔리J가 import를 해대면서 해결되었다.

음 내 성격상 나는 아마 죽을 때가 다 되어서 스프링을 이해할수 있지 않을까

반응형