在生成的服务中禁用 jax-ws 日志记录或静态语句

发布于 2024-12-15 23:37:48 字数 795 浏览 4 评论 0原文

当我使用 jax-ws 生成服务类时,它会生成如下静态语句:

static {
   URL url = null;
   try {
      URL baseUrl;
      baseUrl = com.some.package.with.class.getResource(".");
      url = new URL(baseUrl, "/META-INF/wsdl/thewsdl.wsdl");
       } catch (MalformedURLException e) {
         logger.warning("Failed to create URL for the wsdl Location: '/META-INF/wsd/thewsdl.wsdl', retrying as a local file");
         logger.warning(e.getMessage());
    }
    SERVICE_WSDL_LOCATION = url;
}

我们的 WSDL 在构建时被打包在 jar meta-inf 内,并且我们使用自己的工厂来正确构建各种服务,使用的构造函数采用URL wsdlLocation、QName 服务名称。因此,这个静态声明最终会抛出误导性警告,但这对我们来说并不是真正的问题。我也无法轻松地将记录器配置为忽略它们(我可以告诉),因为每个服务都有自己的命名空间(com.some.package)我们有很多不同的包,我宁愿能够做一些通用的事情而不是必须列出日志配置中的每个服务类。

有没有办法让 jax-ws 根本不生成这个静态块?或者有谁知道一种简单的方法来一次性禁用所有服务类的日志记录?

When I generate service classes with jax-ws it generates a static statement like this:

static {
   URL url = null;
   try {
      URL baseUrl;
      baseUrl = com.some.package.with.class.getResource(".");
      url = new URL(baseUrl, "/META-INF/wsdl/thewsdl.wsdl");
       } catch (MalformedURLException e) {
         logger.warning("Failed to create URL for the wsdl Location: '/META-INF/wsd/thewsdl.wsdl', retrying as a local file");
         logger.warning(e.getMessage());
    }
    SERVICE_WSDL_LOCATION = url;
}

Our WSDL's are packaged inside the jar meta-inf at the time we build, and we use our own factories to properly construct the various servies using the constructor that takes URL wsdlLocation, QName serviceName. So this static statement ends up throwing misleading warnings that are not really a problem for us. I also cannot easily configure the logger to ignore them (that I can tell) because each service is its own namespace (com.some.package) We have a lot of different packages and I would rather be able to do something universal than having to list each service class in the log config.

Is there any way to have jax-ws not generate this static block at all? or does anyone know of a easy way to disable logging for all service classes in one swoop?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情话墙 2024-12-22 23:37:48

我从来没有找到一个好的答案。一个kludge修复是将wsdl位置设置为http,例如 http://localhost:8080/ /META-INF/wsdl/thewsdl.wsdl

这会阻止静态块抛出警告,但随后要求您在需要时操纵该位置构建服务。只是以一恶报恶。

I never found a good answer for this. A kludge fix is to set the wsdl location to http like http://localhost:8080//META-INF/wsdl/thewsdl.wsdl

This stops the static block from throwing the warning but then requires you to manipulate the location when you want to construct the service. Just handing in one evil for another.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文