스프링 스타터 프로젝트 HelloWorld

1 개요[ | ]

Spring Starter Project HelloWorld
스프링 스타터 프로젝트 HelloWorld
  • CLI 상에서 Hello World 출력
  • jar로 추출하여 다른 컴퓨터에서 STS 없이 단독으로 실행가능하도록 해보자.

2 새 프로젝트[ | ]

  • Package Explorer의 빈공간에서 우클릭 --- New --- Spring Starter Project
  • "New Spring Starter Project" --- Name: HelloWorld --- [Next >] --- [Finish]

3 실행[ | ]

  • ▶ 버튼 클릭
  • "Run As" --- Spring Boot App 선택 --- OK
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.3.RELEASE)

2017-05-08 10:27:05.588  INFO 3732 --- [           main] com.example.HelloWorldApplication        : Starting HelloWorldApplication on WIN-QAWM7YG1SGO with PID 3732 (D:\workspace-sts\HelloWorld\target\classes started by user2 in D:\workspace-sts\HelloWorld)
2017-05-08 10:27:05.598  INFO 3732 --- [           main] com.example.HelloWorldApplication        : No active profile set, falling back to default profiles: default
2017-05-08 10:27:05.707  INFO 3732 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4d826d77: startup date [Mon May 08 10:27:05 KST 2017]; root of context hierarchy
2017-05-08 10:27:06.583  INFO 3732 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-05-08 10:27:06.598  INFO 3732 --- [           main] com.example.HelloWorldApplication        : Started HelloWorldApplication in 1.422 seconds (JVM running for 2.281)
2017-05-08 10:27:06.610  INFO 3732 --- [       Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@4d826d77: startup date [Mon May 08 10:27:05 KST 2017]; root of context hierarchy
2017-05-08 10:27:06.613  INFO 3732 --- [       Thread-2] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

4 HelloWorldApplication.java 수정[ | ]

package com.example;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class HelloWorldApplication {

	public static void main(String[] args) {
		SpringApplication.run(HelloWorldApplication.class, args);
		System.out.println( "Hello, World!" );
	}
}
→ Hello, World! 출력

5 실행 2[ | ]

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.5.3.RELEASE)

2017-05-08 10:29:55.597  INFO 3960 --- [           main] com.example.HelloWorldApplication        : Starting HelloWorldApplication on WIN-QAWM7YG1SGO with PID 3960 (D:\workspace-sts\HelloWorld\target\classes started by user2 in D:\workspace-sts\HelloWorld)
2017-05-08 10:29:55.597  INFO 3960 --- [           main] com.example.HelloWorldApplication        : No active profile set, falling back to default profiles: default
2017-05-08 10:29:55.785  INFO 3960 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@4d826d77: startup date [Mon May 08 10:29:55 KST 2017]; root of context hierarchy
2017-05-08 10:29:56.628  INFO 3960 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2017-05-08 10:29:56.644  INFO 3960 --- [           main] com.example.HelloWorldApplication        : Started HelloWorldApplication in 1.422 seconds (JVM running for 2.285)
Hello, World!
2017-05-08 10:29:56.651  INFO 3960 --- [       Thread-2] s.c.a.AnnotationConfigApplicationContext : Closing org.springframework.context.annotation.AnnotationConfigApplicationContext@4d826d77: startup date [Mon May 08 10:29:55 KST 2017]; root of context hierarchy
2017-05-08 10:29:56.651  INFO 3960 --- [       Thread-2] o.s.j.e.a.AnnotationMBeanExporter        : Unregistering JMX-exposed beans on shutdown

6 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}