Skip to content

Instantly share code, notes, and snippets.

@imasahiro
Created June 5, 2018 19:38
Show Gist options
  • Save imasahiro/51c0ca0ab4331b2c324babdf4e198a62 to your computer and use it in GitHub Desktop.
Save imasahiro/51c0ca0ab4331b2c324babdf4e198a62 to your computer and use it in GitHub Desktop.
class Configuration {
@Bean
HttpServiceRegistrationBean springMvcTomcatService(ServletWebServerApplicationContext applicationContext) {
TomcatWebServer container = (TomcatWebServer) applicationContext.getWebServer();
// Starts the container explicitly to make sure all connectors are write back from serviceConnectors.
container.start();
Connector tomcatConnector = container.getTomcat().getConnector();
return new HttpServiceRegistrationBean()
.setServiceName("MyService")
.setService(TomcatService.forConnector(tomcatConnector)
.decorate(LoggingService.newDecorator()))
.setPathMapping(PathMapping.ofPrefix(endpointPrefix));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment