WS 库:com.sun.xml 与 javax.xml
java WebServices API 和 Java WebServices API 有相同的类。这些包组中的 IMPL,仅包名称不同。
我应该在代码中使用哪些?我更喜欢 NON-com.sun.* 按照 java 约定,但我的依赖项(例如 Spring )仍然使用 com.sun.* 的实现,或者我在 javax.xml 中找不到实现包
有人有经验吗关于这个?
There are identical classes of java WebServices API & IMPL in those packages groups, only package names are different.
Which ones should I use in my code? I would prefer NON-com.sun.* as per java conventions, but still my dependencies ( e.g. Spring ) are using implementations from com.sun.* OR I can't find an implementation package in javax.xml
Does anyone have any experience on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
javax.xml
包 -com.sun
包不是公共 Java API 的一部分,并且可能会在 Java 版本之间发生变化,或者如果您选择它们,它们甚至不存在使用其他人的而不是 Sun 的 Java 实现。请参阅:为什么开发人员不应编写调用“sun”包的程序
我不知道你到底想做什么,但你通常不需要直接处理实现包。通常有工厂类和方法来获取 XML 解析器的实例,并且您的程序不需要知道幕后使用的实现。例如,要获取 SAX 解析器,您可以执行以下操作:
Use the
javax.xml
packages - thecom.sun
packages are not part of the public Java API and may change between Java versions, or they don't even exist if you use someone else's than Sun's Java implementation.See: Why Developers Should Not Write Programs That Call 'sun' Packages
I don't know what exactly you're trying to do, but you normally do not need to deal with the implementation packages directly. Usually there are factory classes and methods to get an instance of for example an XML parser, and your program does not need to know what implementation is used behind the scenes. For example, to get a SAX parser you do: