尝试导入 Jreddit 运行所需的 jar 文件时出现错误。
jreddit 的 github 页面上写着......
Dependencies
JSON-simple
Apache HttpComponents
Apache Commons IO
访问 Maven 存储库网站后,我从以下链接下载 jar 文件..
http://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple
http://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
http://mvnrepository.com/artifact/commons-io/commons-io
并将它们导入到我的 intellij 项目中,我只需
⌘+;在 Mac OS X 上 → 模块 → 依赖项 → 添加... → 项目库 → 附加 Jar
我收到以下错误...
错误消息是:无法解析符号。
最佳答案
我是 jReddit 的现任管理员。
首先,我认为您使用的是旧版本的 jReddit。从表面上看,您正在使用 1.0.0
这是第一个版本。当前版本是1.0.2
。尝试从 here 下载 jar 。
其次,我的建议是使用 maven 包含依赖项,而不是通过手动导入 jar 来包含依赖项。
我为您创建了一个小的 pom.xml 如何创建一个简单的 Maven 项目:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yourcompany.test</groupId>
<artifactId>jreddit-testing</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>jreddit-testing</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.github.jreddit</groupId>
<artifactId>jreddit</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
尝试在src/main/java
中添加源代码
完成后,从命令行运行mvn clean install
(请记住,您需要在本地安装 maven,尽管 AFAIK intellij 附带了嵌入式 maven)。
有关 Maven 的更多信息,请查看 this guy
关于java - 为 JReddit 导入 Jar 文件时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29468662/