简体   繁体   English

包com.sun.xml.internal.bind.v2.model.annotation不存在

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

I'm trying to use a solution for serializing exceptions using jaxb. 我正在尝试使用jaxb序列化异常的解决方案。 ( http://forums.java.net/jive/thread.jspa?messageID=256122 ) 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. 当我在Eclipse中编译并运行我的代码时,它工作正常。 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". 但是当我使用Maven编译代码时,它无法抱怨com.sun包,例如“package 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. eclipse和maven都使用JDK 1.6,所以我不明白为什么会这样。 Aren't those com.sun classes inside the JDK? JDK中不是那些com.sun类吗?

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并复制了我需要的信息并使用了它。

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. JDK中的Sun类是前缀sun。*并且不是公共支持的接口的一部分,因此应谨慎使用。 From the Sun FAQ : 来自太阳常见问题

The classes that Sun includes with the Java 2 SDK, Standard Edition, fall into package groups java. Sun在Java 2 SDK标准版中包含的类属于包组java。 , javax. ,javax。 , org.* and sun. ,org。*和太阳。 . All but the sun. 除了太阳以外的所有。 packages are a standard part of the Java platform and will be supported into the future. 软件包是Java平台的标准部分,将来会得到支持。 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). ,在Java平台之外,可以在OS平台(Solaris,Windows,Linux,Macintosh等)上有所不同,并且可以随时更改,而无需通知SDK版本(1.2,1.2.1,1.2.3等) )。 Programs that contain direct calls to the sun. 包含直接调用太阳的程序。 packages are not 100% Pure Java. 包不是100%纯Java。 In other words: 换一种说法:

The java. java。 , javax. ,javax。 and org.* packages documented in the Java 2 Platform Standard Edition API Specification make up the official, supported, public interface. Java 2平台标准版API规范中记录的org。*包构成了官方支持的公共接口。

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. 如果Java程序直接只调用这些包中的API,它将在所有兼容Java的平台上运行,而不管底层的OS平台如何。

The sun.* packages are not part of the supported, public interface. sun。*包不是受支持的公共界面的一部分。

A Java program that directly calls into sun.* packages is not guaranteed to work on all Java-compatible platforms. 直接调用sun。*包的Java程序不能保证在所有兼容Java的平台上运行。 In fact, such a program is not guaranteed to work even in future versions on the same platform. 实际上,即使在同一平台上的未来版本中,也不能保证这样的程序能够工作。

Having said that, those classes you listed are available on the JBoss repository in the following artifact: 话虽如此,您列出的那些类在以下工件中的JBoss存储库中可用:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 引起:java.lang.ClassNotFoundException:com.sun.xml.bind.v2.model.annotation.AnnotationReader - Caused by: java.lang.ClassNotFoundException: com.sun.xml.bind.v2.model.annotation.AnnotationReader 包com.sun.xml.internal.messaging.saaj.soap.dynamic不存在 - package com.sun.xml.internal.messaging.saaj.soap.dynamic does not exist 如何解决netbean javafx应用程序中不存在com.sun.org.apache.xml.internal.security包 - How to solve com.sun.org.apache.xml.internal.security package does not exist in netbean javafx application 在 Jenkins 上构建失败:错误:package com.sun.Z0F635D0E0F3874FFF8B581C1.ws.不存在。 - Build on Jenkins fails: error: package com.sun.xml.internal.ws.client does not exist 包com.sun.org.apache.xml.internal.security.utils.Base64不存在 - Package com.sun.org.apache.xml.internal.security.utils.Base64 does not exist Maven:包com.sun.istack.internal不存在 - Maven: package com.sun.istack.internal does not exist com.sun.xml.internal.ws.client 不存在 - com.sun.xml.internal.ws.client does not exist 生成 GUI 源时未找到 Class java.lang.NoClassDefFoundError: com/sun/xml/bind/v2/model/annotation/AnnotationReader [Codenameone] - Class not found while generating the GUI sources java.lang.NoClassDefFoundError: com/sun/xml/bind/v2/model/annotation/AnnotationReader [Codenameone] 如何解决javac编译器错误“包com.sun.tools.internal.ws.processor.model不存在”? - How do I solve javac compiler error, “package com.sun.tools.internal.ws.processor.model does not exist”? 在 JBoss AS 7 中找不到 JAXB com.sun.xml.internal.bind.v2.ContextFactory 类 - JAXB com.sun.xml.internal.bind.v2.ContextFactory Class Not Found in JBoss AS 7
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM