I have an extra servlet I need to register in my application. However with Spring Boot and its Java Config, I can\'t just add servlet mappings in a web.xml file
If you're using embedded server, you can annotate with @WebServlet your servlet class:
@WebServlet(urlPatterns = "/example")
public class ExampleServlet extends HttpServlet
From @WebServlet:
Annotation used to declare a servlet.
This annotation is processed by the container at deployment time, and the corresponding servlet made available at the specified URL patterns.
And enable @ServletComponentScan on a base class:
@ServletComponentScan
@EntityScan(basePackageClasses = { ExampleApp.class, Jsr310JpaConverters.class })
@SpringBootApplication
public class ExampleApp
Please note that @ServletComponentScan will work only with embedded server:
Enables scanning for Servlet components (filters, servlets, and listeners). Scanning is only performed when using an embedded web server.
More info: The @ServletComponentScan Annotation in Spring Boot