在编译时找不到com.sun.xml.internal.ws.developer.JAXWSProperties [英] com.sun.xml.internal.ws.developer.JAXWSProperties not found at compile
问题描述
我们在代码中使用 com.sun。*
包中的类 JAXWSProperties
来设置超时这样的属性:
We used the class JAXWSProperties
from the com.sun.*
package in the code in order to set timeout properties like this:
import com.sun.xml.internal.ws.developer.JAXWSProperties;
...
Map<String, Object> ctxt = ((BindingProvider) port).getRequestContext();
ctxt.put(JAXWSProperties.CONNECT_TIMEOUT, 10000);
它在本地Eclipse中编译良好,但在连续集成系统上没有编译(两者都使用JDK 1.6) 。通过研究这个问题,我了解到应该避免使用 com.sun。*
包。
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.
所以我的问题是:
- 导致编译时导入失败的原因是什么?
- 应该使用什么代替
JAXWSProperties
?
- What causes the failed import at compile time?
- What should be used instead of
JAXWSProperties
?
推荐答案
我'在将我们的一个项目转换为在Maven下运行时,我遇到了同样的问题。
I've just had pretty much the same problem while converting one of our projects to run under Maven.
我发现的解决方案并不是一个理想的解决方案,实际上它是更多的是cludge而不是fix,尽管它确实通过编译器运行。和你一样,我对这个问题进行了一些研究,发现Sun的评论说这些软件包在编译器中是隐藏的,但可供JVM使用。
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.
因此,我找到的解决方案是简单地找到常量指向的字符串,并在本地使用。
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.
这篇关于在编译时找不到com.sun.xml.internal.ws.developer.JAXWSProperties的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!