包com.sun.xml.internal.bind.v2.model.annotation不存在 [英] package com.sun.xml.internal.bind.v2.model.annotation does not exist

查看:183
本文介绍了包com.sun.xml.internal.bind.v2.model.annotation不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用jaxb序列化异常的解决方案。 ( http://forums.java.net/jive/thread.jspa?messageID= 256122

I'm trying to use a solution for serializing exceptions using jaxb. (http://forums.java.net/jive/thread.jspa?messageID=256122)

我需要为该解决方案实现的类需要引用以下com.sun类。

The class I need to implement for that solution requires referencing the following com.sun classes.

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;

当我在Eclipse中编译并运行我的代码时,它运行正常。但是当我使用Maven编译代码时,它无法抱怨com.sun包,例如package com.sun.xml.internal.bind.v2.model.annotation不存在。

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都在使用JDK 1.6,所以我不明白为什么会这样。 JDK中不是那些com.sun类吗?

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?

编辑:
我最终决定它是不可能的。我只是创建了一个新的bean并复制了我需要的信息并使用了它。

I ultimately decided it just wasn't possible. I simply created a new bean and copied over the information I needed and used that.

推荐答案

如果一个类在包中 com.sun。* ,它只是意味着它是由Sun开发的,而不是它是JDK的一部分。

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.

JDK中的Sun类以 sun。* 为前缀,不属于公共支持的接口,因此应谨慎使用。来自 Sun常见问题解答

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:


Sun在Java 2 SDK标准版中包含的类属于软件包组java。,javax。,org。*和太阳。。除了sun。包之外的所有包都是Java平台的标准部分,并且将来会得到支持。通常,Java平台之外的sun。等软件包在操作系统平台(Solaris,Windows,Linux,Macintosh等)之间可能会有所不同,并且可能随时更改,而无需通知SDK版本( 1.2,1.2.1,1.2.3等)。包含对sun。包的直接调用的程序不是100%Pure Java。换句话说:

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:

Java 2平台标准版API规范中记录的java。,javax。和org。*包构成官方的,受支持的公共接口。

The java., javax. and org.* packages documented in the Java 2 Platform Standard Edition API Specification make up the official, supported, public interface.

如果Java程序直接调用这些包中的API,它将在所有兼容Java的平台上运行,无论底层OS平台如何。

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.

sun。*软件包不是支持的公共界面的一部分。

The sun.* packages are not part of the supported, public interface.

直接调用sun。*包的Java程序保证可以在所有兼容Java的平台上运行。实际上,即使在同一平台上的未来版本中,也不能保证这样的程序能够工作。

A Java program that directly calls into sun.* packages is not guaranteed 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.

话虽如此,你列出的那些类可以在 JBoss 存储库:

Having said that, those classes you listed are available on the JBoss repository in the following artifact:

<dependency>
  <groupId>javax.xml</groupId>
  <artifactId>jaxb-impl</artifactId>
  <version>2.1</version>
</dependency>

这篇关于包com.sun.xml.internal.bind.v2.model.annotation不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆