我认为我的运行配置有问题。我试图做的时候
@Context private HttpServletRequest request;
我收到错误
There is more than one Bean with type javax.servlet.http.HttpServletRequestQualifiers: [@javax.ws.rs.core.Context()]
for injection into Field Injection Point, field name : request, Bean Owner : [xxx, Name:xxx, WebBeans Type:MANAGED, API Types:[java.lang.Object,xxx,xxx], Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any,javax.inject.Named]]
found beans:
HttpServletRequest, Name:null, WebBeans Type:THIRDPARTY, API Types:[javax.servlet.http.HttpServletRequest,java.lang.Object], Qualifiers:[javax.ws.rs.core.Context,javax.enterprise.inject.Any] from jar:file:/C:/enterprise-server-dozer-1.6.5/lib/servlet-api.jar!/javax/servlet/http/HttpServletRequest.class
Bean1, Name:null, WebBeans Type:THIRDPARTY, API Types:[javax.servlet.http.HttpServletRequest], Qualifiers:[javax.ws.rs.core.Context] from unknown path
如果我尝试使用
,我会收到类似的错误javax.ws.rs.core.Request;
使用Request,错误指向在同一个jar文件中查找相同的bean。就像豆子被创造了两次。有什么明显我可以检查解决这个问题吗?
答案 0 :(得分:1)
这一点
C:/enterprise-server-dozer-1.6.5/lib/servlet-api.jar
看起来您已经在Web应用程序中包含了Servlet API JAR,这是不允许的。
Servlet API由servlet容器提供。使用Maven时,应使用范围provided
声明依赖项。
在您的应用程序中重复使用JAR可能会考虑重复的bean。