I am using dropwizard version 0.7.1. It is configured to use "random" (ephemeral?) port (server.applicationConnectors.port=0). I want to get what port is really in use after startup, but I can't find any information how to do that.
Add your configuration to the command line after server . See dropwizard.codahale.com/getting-started/#running-your-service for more information. It should have the desired effect. Perfect!
Dropwizard uses Logback for its logging backend. It provides an slf4j implementation, and even routes all java. util. logging , Log4j, and Apache Commons Logging usage through Logback.
Overview. Dropwizard is an open-source Java framework used for the fast development of high-performance RESTful web services. It gathers some popular libraries to create the light-weight package. The main libraries that it uses are Jetty, Jersey, Jackson, JUnit, and Guava.
Bootstrap is the pre-start (temp) application environment, containing everything required to bootstrap a Dropwizard command.
You can get a serverStarted
callback from a lifecycle listener to figure this out.
@Override
public void run(ExampleConfiguration configuration, Environment environment) throws Exception {
environment.lifecycle().addServerLifecycleListener(new ServerLifecycleListener() {
@Override
public void serverStarted(Server server) {
for (Connector connector : server.getConnectors()) {
if (connector instanceof ServerConnector) {
ServerConnector serverConnector = (ServerConnector) connector;
System.out.println(serverConnector.getName() + " " + serverConnector.getLocalPort());
// Do something useful with serverConnector.getLocalPort()
}
}
}
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With