简体   繁体   English

如果将jar文件下载到项目中并将其包含在“构建路径”中,该如何将杰克逊类导入Java文件中?

[英]How do I import jackson classes into a Java file if I've downloaded the jar file into my project and included it into my Build Path?

Most resources online tell me add the Maven dependencies, but I haven't found a working description on how I use the Jackson jar file once I've downloaded it into my project. 在线上的大多数资源都告诉我添加了Maven依赖项,但是一旦将其下载到项目中后,我还没有找到有关如何使用Jackson罐子文件的有效描述。

I'm a beginner in Java. 我是Java的初学者。 Thank you for your help. 谢谢您的帮助。

As simple as possible: 尽可能简单:

在此处输入图片说明

How to write an import into a java file to use the jar file from this location? 如何将导入内容写入Java文件以使用此位置的jar文件?

What I understood by your post is that you are not able to access any class of a library you've imported into your workspace. 我从您的帖子中了解到,您无法访问已导入到工作区中的库的任何类。

Follow mentioned steps, Right click on your project --> Properties --> Java Build Path --> Libraries --> Add External Jar --> Choose jackson-core-2.8.7.jar which you've recently downloaded and that's it. 按照上述步骤操作,右键单击您的项目->属性-> Java构建路径->库->添加外部Jar->选择您最近下载的jackson-core-2.8.7.jar,即它。

Now go to your Java Class where you need any class of jackson library and import the class from the library you need to use/extend. 现在转到需要任何类的jackson库的Java类,并从需要使用/扩展的库中导入该类。 Refer screenshot attached below for further reference. 请参考下面所附的屏幕截图,以获取更多参考。

在此处输入图片说明

The question was answered in the Answer comments by @shmosel @shmosel在“答案”评论中回答了该问题

import com.fasterxml.jackson.core.JsonParser; 导入com.fasterxml.jackson.core.JsonParser;

The answer by @Pratik Ambani is very useful too. @Pratik Ambani的回答也非常有用。

Also, not just the jackson core has to be imported but also databind and annotations. 此外,不仅必须导入杰克逊核心,还需要导入数据绑定和注释。

The files can be found here: http://repo1.maven.org/maven2/com/fasterxml/jackson/ 可以在以下位置找到文件: http : //repo1.maven.org/maven2/com/fasterxml/jackson/

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

相关问题 将.jar文件添加到netbeans中的项目后,如何将其中的类导入到netbeans中的项目中? - After adding a .jar file to a project in netbeans, how do I import classes in it to my project in netbeans? 如何从我的java类构建库文件(jar文件)? - how to build a library file (jar file) from my java classes? 如何从我的库中已有的jar文件导入? (Netbeans Java) - How do I import from a jar file that is already in my library? (Netbeans Java) 运行Java时,如何解决输入JAR文件完整路径的需要? - When running java how do I get around the need to enter the full path of my JAR file? 如何将Java准确地编译为JAR文件? - How exactly do I compile my Java into a JAR file? 如何将所有类导入jar文件? - how do I import all the classes in a jar file? 如何从现有的Jar和我自己的类制作Jar文件? - How do i make a Jar file from an already existing Jar and my own classes? 如何从主Java应用程序运行jar文件? jar文件必须在我的Java项目中 - How can I run a jar file from my main Java app? Where jar file must be in my Java project 如何在Eclipse中将ImageJ添加到构建路径中,以及在哪里可以找到ImageJ .jar文件? - How can I add ImageJ to my build path in Eclipse, and where can I find the ImageJ .jar file? 如何创建Java项目的可执行文件(生成,测试和运行)? - How do I create an executable file (build, test and run) of my java project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM