Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.