I am using javax.servlet.Registration
to dynamically configure/register servlets.
I'd like to know how I could configure multiple provider packages for Jersey
. I can add a single package using the setInitParamater
method as follows:
public class MyWebInitalization implements WebApplicationInitializer {
@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
//... some code
final ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher", ServletContainer.class);
dispatcher.setInitParameter("jersey.config.server.provider.packages", "com.package1"); // how to add more packages?
//... more code
}
}
To give you an idea of what I mean, this is an equivalent if I would have used web.xml:
<servlet>
...
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.package1;com.package2</param-value>
</init-param>
...
</servlet>
Do you try something like this dispatcher.setInitParameter("jersey.config.server.provider.packages", "com.package1;com.package2");
?
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