Notice
Recent Posts
Recent Comments
Link
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

개발자 되버리기

Springboot 에서 HelloWorld 띄우기 본문

개발/Spring_Boot

Springboot 에서 HelloWorld 띄우기

구본익 2018. 6. 21. 22:49

해당 포스팅은 티스토리 블로그 이름 : 기억보단 기록을 이라는 곳을 참고하여 작성하였습니다.


IDE : inteliJ Ultimate

Git Tools : Ubuntu 16.04 LTS (in Windosw)

OS : Windows 10 Pro

SpringBoot : 2.0.3

Java8

Gradle


이후 모든 소스코드는 https://github.com/Koobonik/Spring_Boot 로 오시면 보실 수 있습니다.


Github 푸시 방법은 윈도우10 에 내장되어 있는 Ubuntu를 이용해서 포스팅 하게 됩니다.



- 디렉토리 구조 입니다. -





WebRestController.java 에 삽입된 소스코드 입니다.

package com.devkoo.webservice.web;

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

@RestController
public class WebRestController {

@GetMapping("/hello") // 웹에서 /hello 라는 요청이 있을경우
public String hello() {
return "HelloWorld";
} // HelloWorld 라는 문구 반환

@GetMapping("/welcome")
public String welcome(){
return "Welcome to Spring Boot";
} // 조금 더 응용해서 다른 문구도 출력가능하게
}



@GetMapping 메소드는 클라이언트가 해당되는 글을 요청했을 경우 반환해주는 일을 합니다.



예시

    


8080 포트는 무슨 이유에서인지 사용불가하여 대체로 9000 포트를 사용하였습니다.




포트 설정 방법은

application.properties 에서 server.port=9000 을 입력해주시면 됩니다.











Comments