Skip to content

Configuring the port or hostname

johnmcclean-aol edited this page Oct 27, 2015 · 1 revision

Configuring the port

Microserver will by default start a new server on Port 8080. If another, embedded, Microservice is already running on that port it will use 8081 (and so on).

Users can force a service to use a particular port instance via a property, the name of the property follows the scheme .port. I.e. if we have service using the context 'order-builder' then the property to override the port for order-builder is order-builder.port.

 <context>.port=<port num>
@Rest
@Path("/test")
public class SimpleApp {

   public static void main(String[] args){
   new MicroserverApp(()->"test-app").run();
  }
  @GET
  public String myEndPoint(){
   return "hello world!";
  }
}
test-app.port=8083

Configuring the host name

By default the host name used is gathered from InetAddress.getLocalHost().getHostName(). You can configure the hostname for a service in instance.properties via

  <context>.host=hostname