Skip to content

Instantly share code, notes, and snippets.

@tuxfight3r
Created February 17, 2020 22:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxfight3r/05239cd19c5efebf569e3bd80f8a7bf7 to your computer and use it in GitHub Desktop.
Save tuxfight3r/05239cd19c5efebf569e3bd80f8a7bf7 to your computer and use it in GitHub Desktop.
sample springboot application
//$ 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