如何在 Eclipse 中解析 javax.xml.bind.JAXBContext?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5849638/
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
How to resolve javax.xml.bind.JAXBContext in Eclipse?
提问by MarcoS
In my Android app I use:
在我的 Android 应用程序中,我使用:
import javax.xml.bind.JAXBContext;
But I get:
但我得到:
The import javax.xml.bind cannot be resolved
The import javax.xml.bind cannot be resolved
I do have com.viewstreet.java.eclipse.jaxbplugin.JAXBPlugin
in my plugins list.
我有com.viewstreet.java.eclipse.jaxbplugin.JAXBPlugin
我的插件列表。
采纳答案by CommonsWare
Put the JAR in the project's libs/
directory, then add it to the build path via the Add JARs button. That's my standard recipe, and it seems to work, and it has the advantage of putting the JAR in the right spot for command-line builds as well.
将 JAR 放在项目libs/
目录中,然后通过 Add JARs 按钮将其添加到构建路径中。这是我的标准配方,它似乎有效,而且它的优点是将 JAR 放在命令行构建的正确位置。
At this point, though, I suspect that you will get a compile error. Generally, you cannot import classes in the java
and javax
packages into an Android project.
但是,此时,我怀疑您会收到编译错误。通常,您不能将java
和javax
包中的类导入到 Android 项目中。
回答by shreeramaute
@commonsware is correct , just add respctive JAXB API jars in lib folder of your projet or in case of maven project add dependency in pom file
@commonsware 是正确的,只需在项目的 lib 文件夹中添加相应的 JAXB API jar,或者在 maven 项目的情况下在 pom 文件中添加依赖项
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
viz in my case on linux, solved the issue
viz 在我的 linux 上,解决了这个问题
回答by dipak
Download jax-b.jar
and add it as external jar in your project.
下载jax-b.jar
并将其作为外部 jar 添加到您的项目中。
回答by Jonathon Faust
Any import cannot be resolved
in Java means a class you referenced is not found anywhere on the classpath. You need the library you're trying to use added to your classpath. In Eclipse, that's in project properties in the Java Build Path => Libraries tab. If you don't have the jar file that contains the API you're trying to use, you probably need to get it from http://jaxb.java.net/.
import cannot be resolved
Java 中的Any表示在类路径中的任何位置都找不到您引用的类。您需要将尝试使用的库添加到类路径中。在 Eclipse 中,它位于 Java Build Path => Libraries 选项卡中的项目属性中。如果您没有包含您尝试使用的 API 的 jar 文件,您可能需要从http://jaxb.java.net/获取它。