gpt4 book ai didi

java - 未使用 @Resource 注入(inject) WebServiceContext

转载 作者:行者123 更新时间:2023-11-28 23:42:16 24 4
gpt4 key购买 nike

我知道之前有人问过这个问题,但没有一个解决方案对我有用。可能是因为他们主要使用符合 EE 的应用程序服务器,这不是我的情况。

我在 jetty 上运行我的网络服务(通过 Eclipse)仅用于开发。但即使是部署,我也会使用 Tomcat 7。因此,无论是开发还是生产,我都不会使用兼容 JavaEE 的服务器。

  • 那么是否仍然可以将 WebServiceContext 注入(inject)我的网站服务 ?

我已经尝试了以下方法,但没有用

@WebService
@BindingType(SOAPBinding.SOAP12HTTP_BINDING)
public class IxProIntegration {
// Tried this, didn't work
@Resource
private WebServiceContext wsContext;

// After commenting the @Resource annotation on the wsContext field
// And adding the annotation here, this still didn't work.
@Resource
@WebMethod(exclude = true)
public void setContext(WebServiceContext context) {
this.wsContext = context;
}
  • 当有人友善地给出答案时,我很想知道来自哪里他得到那个答案了吗?

最佳答案

我正在使用名为 Tapestry 的依赖项注入(inject)框架。 Tapestry 正在管理服务实例化。但是 Web 服务不是由 JAX-WS 管理的。这就是上下文始终为 null 的原因。我 asked a new question related to the subject ,以防有人需要答案。

关于java - 未使用 @Resource 注入(inject) WebServiceContext,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18525723/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com