【问题标题】:Importing Jar files for JReddit giving error为 JReddit 导入 Jar 文件时出现错误
【发布时间】:2015-04-06 09:36:46
【问题描述】:

尝试导入 Jreddit 运行所需的 jar 文件时出现错误。

在 jreddit 的 github 页面上它说 ...

依赖关系

JSON-简单

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

我收到以下错误...

错误信息是:无法解析符号。

【问题讨论】:

标签: java maven intellij-idea reddit jreddit


【解决方案1】:

我是 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

【讨论】:

  • 嘿,谢谢你的回答,我遇到了一个小问题,运行 mvn clean install 后,它下载包很好,但是当我运行程序时我得到错误 Error:java:找不到目录:/Users/"myname"/Documents/workspace/jredditTesting/target/generated-sources/annotations
  • 从 intellij 更改为 eclipse 后,我让它工作了,现在我想知道如何检索前 10 个 cmets 以提交世界新闻 subreddit?
猜你喜欢
  • 1970-01-01
  • 2019-04-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-29
  • 2015-12-24
  • 1970-01-01
  • 2016-07-23
相关资源
最近更新 更多