Skip to content

Instantly share code, notes, and snippets.

@mstykt
Created May 11, 2020 17:12
Show Gist options
  • Save mstykt/7152805ee293534675c418a8e3ebaed3 to your computer and use it in GitHub Desktop.
Save mstykt/7152805ee293534675c418a8e3ebaed3 to your computer and use it in GitHub Desktop.
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