Java 包 com.sun.xml.internal.bind.v2.model.annotation 不存在
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1269319/
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
package com.sun.xml.internal.bind.v2.model.annotation does not exist
提问by HappyEngineer
I'm trying to use a solution for serializing exceptions using jaxb. (http://forums.java.net/jive/thread.jspa?messageID=256122)
我正在尝试使用一种使用 jaxb 序列化异常的解决方案。( http://forums.java.net/jive/thread.jspa?messageID=256122)
The class I need to implement for that solution requires referencing the following com.sun classes.
我需要为该解决方案实现的类需要引用以下 com.sun 类。
import com.sun.xml.internal.bind.v2.model.annotation.AbstractInlineAnnotationReaderImpl;
import com.sun.xml.internal.bind.v2.model.annotation.Locatable;
import com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader;
import com.sun.xml.internal.bind.v2.model.annotation.RuntimeInlineAnnotationReader;
When I compile and run my code inside of Eclipse it works fine. But when I compile the code using Maven it fails complaining about the com.sun packages like "package com.sun.xml.internal.bind.v2.model.annotation does not exist".
当我在 Eclipse 中编译并运行我的代码时,它工作正常。但是当我使用 Maven 编译代码时,它无法抱怨 com.sun 包,如“包 com.sun.xml.internal.bind.v2.model.annotation 不存在”。
Both eclipse and maven are using JDK 1.6, so I don't understand why this is happening. Aren't those com.sun classes inside the JDK?
eclipse 和 maven 都使用 JDK 1.6,所以我不明白为什么会这样。那些 com.sun 类不是 JDK 里面的吗?
EDIT: I ultimately decided it just wasn't possible. I simply created a new bean and copied over the information I needed and used that.
编辑:我最终决定这是不可能的。我只是创建了一个新 bean 并复制了我需要的信息并使用了它。
采纳答案by Rich Seller
If a class is in the package com.sun.*, it just means it was developed by Sun, not that it is part of the JDK.
如果一个类在包com.sun.* 中,则仅表示它是由 Sun 开发的,而不是 JDK 的一部分。
Sun classes in the JDK are prefixed sun.*and are not part of the public supported interface so should be used with care. From the Sun FAQ:
JDK 中的 Sun 类以sun.*为前缀,并且不是公共支持接口的一部分,因此应谨慎使用。来自太阳常见问题解答:
The classes that Sun includes with the Java 2 SDK, Standard Edition, fall into package groups java., javax., org.* and sun.. All but the sun.packages are a standard part of the Java platform and will be supported into the future. In general, packages such as sun., that are outside of the Java platform, can be different across OS platforms (Solaris, Windows, Linux, Macintosh, etc.) and can change at any time without notice with SDK versions (1.2, 1.2.1, 1.2.3, etc). Programs that contain direct calls to the sun.packages are not 100% Pure Java. In other words:
The java., javax.and org.* packages documented in the Java 2 Platform Standard Edition API Specification make up the official, supported, public interface.
If a Java program directly calls only API in these packages, it will operate on all Java-compatible platforms, regardless of the underlying OS platform.
The sun.* packages are notpart of the supported, public interface.
A Java program that directly calls into sun.* packages is notguaranteed to work on all Java-compatible platforms. In fact, such a program is not guaranteed to work even in future versions on the same platform.
Sun 包含在 Java 2 SDK 标准版中的类属于包组 java。,javax。, org.* 和 sun. . 除了太阳。包是 Java 平台的标准部分,将来会得到支持。一般来说,包如sun。,在 Java 平台之外,在不同的操作系统平台(Solaris、Windows、Linux、Macintosh 等)之间可能不同,并且可以随时更改,恕不另行通知 SDK 版本(1.2、1.2.1、1.2.3 等) )。包含直接调用太阳的程序。包不是 100% 纯 Java。换句话说:
爪哇。,javax。Java 2 平台标准版 API 规范中记录的 org.* 和 org.* 包构成了官方的、受支持的公共接口。
如果一个 Java 程序直接只调用这些包中的 API,它将在所有兼容 Java 的平台上运行,而不管底层 OS 平台如何。
sun.* 包不是受支持的公共接口的一部分。
直接调用 sun.* 包的 Java 程序不能保证在所有与 Java 兼容的平台上都能运行。事实上,即使在同一平台上的未来版本中,也不能保证这样的程序可以工作。
Having said that, those classes you listed are available on the JBossrepository in the following artifact:
话虽如此,您列出的那些类在以下工件的JBoss存储库中可用:
<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1</version>
</dependency>