Created
May 11, 2020 17:12
-
-
Save mstykt/7152805ee293534675c418a8e3ebaed3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.demo; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.core.env.Environment; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
@SpringBootApplication | |
public class DemoApplication { | |
public static void main(String[] args) { | |
SpringApplication.run(DemoApplication.class, args); | |
} | |
} | |
@RestController | |
@RequestMapping("/") | |
class DemoController { | |
private final Environment env; | |
DemoController(Environment env) { | |
this.env = env; | |
} | |
@GetMapping | |
public String sayHi() { | |
return "Hi from Demo application with port: " + env.getProperty("local.server.port"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment