java com.sun.xml.internal.ws.developer.JAXWSProperties 在编译时未找到

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7358724/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 19:38:37  来源:igfitidea点击:

com.sun.xml.internal.ws.developer.JAXWSProperties not found at compile

jax-wsjava

提问by Alexander Rühl

We used the class JAXWSPropertiesfrom the com.sun.*package in the code in order to set timeout properties like this:

我们使用了类JAXWSPropertiescom.sun.*包中的代码,以这样的设置超时属性:

import com.sun.xml.internal.ws.developer.JAXWSProperties;
...
Map<String, Object> ctxt = ((BindingProvider) port).getRequestContext();
ctxt.put(JAXWSProperties.CONNECT_TIMEOUT, 10000);

It compiles fine in the local Eclipse, but not on a continuous integration system (both using JDK 1.6). From researching this problem, I learned that the com.sun.*package should be avoided.

它在本地 Eclipse 中编译良好,但在持续集成系统(均使用 JDK 1.6)上编译不正常。通过研究这个问题,我了解到com.sun.*应该避免使用包。

So my questions are:

所以我的问题是:

  • What causes the failed import at compile time?
  • What should be used instead of JAXWSProperties?
  • 编译时导入失败的原因是什么?
  • 应该用什么代替JAXWSProperties

回答by Crollster

I've just had pretty much the same problem while converting one of our projects to run under Maven.

在将我们的一个项目转换为在 Maven 下运行时,我遇到了几乎相同的问题。

The solution I found, isn't really an ideal solution, in fact it's more of a "cludge" than a "fix," although it does run through the compiler OK. Like you I did a bit of research on this issue, and found a comment from Sun saying that these packages are hidden from the compiler, but are available to the JVM.

我发现的解决方案并不是真正的理想解决方案,实际上它更像是“杂物”而不是“修复”,尽管它确实可以通过编译器运行。像你一样,我对这个问题做了一些研究,发现 Sun 的评论说这些包对编译器是隐藏的,但对 JVM 可用。

So, the solution I found was to simply find the string to which the constant was pointing, and use that locally.

所以,我找到的解决方案是简单地找到常量指向的字符串,并在本地使用它。

In your case it would be:

在您的情况下,它将是:

final static String CONNECT_TIMEOUT = "com.sun.xml.internal.ws.connect.timeout";
....
Map<String, Object> ctxt = ((BindingProvider) port).getRequestContext();
ctxt.put(CONNECT_TIMEOUT, 10000);

As I mentioned, this isn't ideal, and can not be guaranteed to work in future compiler releases, so use with care.

正如我所提到的,这并不理想,并且不能保证在未来的编译器版本中工作,因此请谨慎使用。