@Override @SuppressWarnings("try") public void onStartup(ServletContext servletContext) throws ServletException { if (factory.getPort() == 0) { LOGGER.warn( "spring boot embed web container listen port is 0, serviceComb will not use container's port to handler RESTful request."); return; } // web container did not did listen now. // so mock to listen, and then close. try (ServerSocket ss = new ServerSocket(factory.getPort(), 0, factory.getAddress())) { if (StringUtils.isEmpty(ServletConfig.getServletUrlPattern())) { // ensure the servlet will be instantiated Configuration configuration = (Configuration) DynamicPropertyFactory.getBackingConfigurationSource(); configuration.setProperty(ServletConfig.KEY_SERVLET_URL_PATTERN, ServletConfig.DEFAULT_URL_PATTERN); } ServletUtils.init(servletContext); } catch (IOException e) { throw new ServletException(e); } } }