2012-07-26 58 views
0

我想爲地理位置服務使用Factual Jar文件,但是我已經將Jar文件導入到項目中,但文檔指出pom.xml會告訴您需要哪些依賴關係插入您的項目,讓司機工作。事實上非Maven Java Jar依賴關係

我的問題是我需要導入哪些依賴項以及項目中的哪些地方。我正在使用Netbeans來構建我的Java項目。

pom.xml文件:http://repo1.maven.org/maven2/com/factual/factual-java-driver/1.5.0/factual-java-driver-1.5.0.pom

<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.factual</groupId> 
<artifactId>factual-java-driver</artifactId> 
<version>1.5.0</version> 
<packaging>jar</packaging> 
<name>factual-java-driver</name> 
<description>Factual's officially supported Java driver</description> 
<url>http://github.com/Factual/factual-java-driver</url> 
<scm> 
<connection> 
scm:git:[email protected]:Factual/factual-java-driver.git 
</connection> 
<developerConnection> 
scm:git:[email protected]:Factual/factual-java-driver.git 
</developerConnection> 
<url>[email protected]:Factual/factual-java-driver.git</url> 
<!-- 
url>https://github.com/Factual/factual-java-driver/tree/master</url> <connection>scm:git:git://github.com/Factual/factual-java-driver.git</connection 
--> 
</scm> 
<parent> 
<groupId>org.sonatype.oss</groupId> 
<artifactId>oss-parent</artifactId> 
<version>7</version> 
</parent> 
<licenses> 
<license> 
<name>The Apache Software License, Version 2.0</name> 
<url> 
http://github.com/Factual/factual-java-driver/blob/master/LICENSE.txt 
</url> 
<distribution>repo</distribution> 
</license> 
</licenses> 
<developers> 
<developer> 
<id>aaron</id> 
<name>Aaron Crow</name> 
<email>[email protected]</email> 
</developer> 
</developers> 
<dependencies> 
<dependency> 
<groupId>com.google.guava</groupId> 
<artifactId>guava</artifactId> 
<version>r09</version> 
</dependency> 
<dependency> 
<groupId>com.google.api-client</groupId> 
<artifactId>google-api-client</artifactId> 
<version>1.7.0-beta</version> 
</dependency> 
<dependency> 
<groupId>org.codehaus.jackson</groupId> 
<artifactId>jackson-core-asl</artifactId> 
<version>1.9.1</version> 
</dependency> 
<dependency> 
<groupId>org.codehaus.jackson</groupId> 
<artifactId>jackson-core-lgpl</artifactId> 
<version>1.9.1</version> 
</dependency> 
<dependency> 
<groupId>org.codehaus.jackson</groupId> 
<artifactId>jackson-mapper-asl</artifactId> 
<version>1.9.1</version> 
</dependency> 
<dependency> 
<groupId>commons-io</groupId> 
<artifactId>commons-io</artifactId> 
<version>2.1</version> 
</dependency> 
<dependency> 
<groupId>org.json</groupId> 
<artifactId>json</artifactId> 
<version>20090211</version> 
</dependency> 
<dependency> 
<groupId>junit</groupId> 
<artifactId>junit</artifactId> 
<version>4.4</version> 
<scope>test</scope> 
</dependency> 
</dependencies> 
<properties> 
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
</properties> 
<build> 
<plugins> 
<plugin> 
<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-javadoc-plugin</artifactId> 
<executions> 
<execution> 
<id>attach-javadocs</id> 
<goals> 
<goal>jar</goal> 
</goals> 
</execution> 
</executions> 
</plugin> 
<plugin> 
<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-release-plugin</artifactId> 
<version>2.1</version> 
<configuration> 
<pushChanges>false</pushChanges> 
</configuration> 
</plugin> 
<plugin> 
<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-gpg-plugin</artifactId> 
<executions> 
<execution> 
<id>sign-artifacts</id> 
<phase>verify</phase> 
<goals> 
<goal>sign</goal> 
</goals> 
</execution> 
</executions> 
</plugin> 
<plugin> 
<artifactId>maven-compiler-plugin</artifactId> 
<version>2.3.2</version> 
<configuration> 
<source>1.6</source> 
<target>1.6</target> 
</configuration> 
</plugin> 
<plugin> 
<artifactId>maven-assembly-plugin</artifactId> 
<version>2.2.1</version> 
<configuration> 
<descriptors> 
<descriptor>jar-with-dependencies.xml</descriptor> 
</descriptors> 
<finalName>factual-java-driver</finalName> 
<outputDirectory>target</outputDirectory> 
<workDirectory>target/assembly/work</workDirectory> 
</configuration> 
</plugin> 
<plugin> 
<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-source-plugin</artifactId> 
<version>2.1.2</version> 
<executions> 
<execution> 
<goals> 
<goal>jar</goal> 
</goals> 
</execution> 
</executions> 
</plugin> 
<plugin> 
<groupId>org.apache.maven.plugins</groupId> 
<artifactId>maven-javadoc-plugin</artifactId> 
<version>2.8</version> 
</plugin> 
</plugins> 
</build> 
<!-- 
distributionManagement> <repository> <id>sonatype-nexus-staging</id> <name>Sonatype Staging</name> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> </repository> </distributionManagement 
--> 
</project> 

回答

1

您可以手動從http://mvnrepository.com/下載的依賴關係。 pom.xml中詳細顯示了依賴的名字:

<dependencies> 
    <dependency> 
    <groupId>com.google.guava</groupId> 
    <artifactId>guava</artifactId> 
    <version>r09</version> 
    </dependency> 
    ... 
<dependencies> 

只需選中的artifactId的,看看該怎麼尋找。繼續前進,通過搜索下載它們:

  • 番石榴
  • 谷歌的API客戶端
  • 傑克遜核心 - 翔升
  • 傑克遜核心LGPL
  • 傑克遜映射器 - 翔升
  • commons-io
  • json
  • junit

(小心下載每個依賴關係的正確版本)
最後,您需要import these 8 jar files到您的項目,然後它應該工作。

+0

我能夠在mvnrepository.com上搜索Factual,它提供了Factual Jar的所有依賴關係。 – 2012-07-26 22:55:59

+0

你知道爲什麼我會得到這個錯誤:'線程異常AWT-EventQueue-0「java.lang.NoClassDefFoundError:com/google/api/client/http/HttpResponseException' – 2012-07-27 01:21:30

+0

似乎有一個版本與您的Factual vs google-api-client。 Factual正在使用一個類(HttpResponseException),它在您添加的當前google-api-client.jar中不存在。上面的Pom.xml提到你需要google-api-client的版本'1.7.0-beta';你可以重新檢查你的當前pom.xml,看看導入的google-api-client版本是否匹配?尋找一個正確的依賴版本很爛,但希望你能弄明白:) – cluster00 2012-07-27 22:59:18