Created
February 17, 2020 22:39
-
-
Save tuxfight3r/05239cd19c5efebf569e3bd80f8a7bf7 to your computer and use it in GitHub Desktop.
sample springboot application
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
//$ cat Application.java | |
package hello; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
import org.springframework.boot.context.embedded.LocalServerPort; | |
import java.net.InetAddress; | |
import java.net.UnknownHostException; | |
@SpringBootApplication | |
@RestController | |
public class Application { | |
@RequestMapping("/" ) | |
public String home() { | |
return "<h3>Name: Demo App<br />Version: 1<br />IPAddress: " + getHostAddress(); | |
} | |
private InetAddress getHostAddress() { | |
try { | |
return InetAddress.getLocalHost(); | |
} catch (UnknownHostException ex) { | |
throw new IllegalArgumentException(ex.getMessage(), ex); | |
} | |
} | |
public static void main(String[] args) { | |
SpringApplication.run(Application.class, args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment