jersey容器发布web应用不需要web.xml的开发。
1.新建容器扫描类
package com.example;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;
import org.glassfish.jersey.servlet.ServletContainer;
@WebServlet(
initParams = @WebInitParam(name = "jersey.config.server.provider.packages", value = "com.example"),
urlPatterns = "/webapi/*",
loadOnStartup = 1)
public class AirServlet extends ServletContainer {
private static final long serialVersionUID = 1L;
}
在com.example包中的资源服务类都可以访问到