I have a spring-boot application with a @RestController, and need to register a servlet on a different port, while the RestController is bound to the default port.
I have an application.yml file and a src>main>resources>application.properties file.
This is my Servlet registration class
@Configuration
public class ServletConfig {
private static final Logger LOGGER = LoggerFactory.getLogger (ServletConfig.class);
@Bean
public ServletRegistrationBean<MyServlet> servletRegistrationBean(final ServletContext servletContext){
LOGGER.info("Inside ServletRegistrationBean");
final ServletRegistrationBean <MyServlet> bean = new ServletRegistrationBean <> (new MyServlet (), true, "/endpoint");
bean.setLoadOnStartup (1);
return bean;
}
Here is my MyServlet class:
public class MyServlet extends AbstractXServlet{ private static final Logger LOGGER = LoggerFactory.getLogger (MyServlet.class);
public MyServlet() {
LOGGER.info("Inside MyServlet Constructor");
settings().setMultipartEnabled(false);
final ServletHandlerr servletHandlerr = new ServletHandlerr();
//Http POST Only
handlerRegistry().registerHandler(EHttpMethod.POST, servletHandlerr);
}
}
I want to define the port for the servlet on my application.properties file, different than the default port where all the RestController endpoints are. But right now, I can't get to print any of the log messages. Not sure what i'm doing wrong. Any help is really appreciated.