8

プロジェクトに Google カレンダーの Java API を使用しています。

カレンダー部分は問題ありません。maven はそれをダウンロードして問題なく使用しているようです。

私の問題は、このライブラリの主な依存関係である com.google.api.client api.

特に、このページで説明されている手順に従うと、maven はプロジェクトを適切にコンパイルできません。

package com.google.api.client.extensions.java6.auth.oauth2 does not exist
package com.google.api.client.extensions.jetty.auth.oauth2 does not exist
package com.google.api.client.json.jackson2 does not exist

いくつかのクラスがないため、ファイルをコンパイルできませんが、zip をダウンロードして、maven を使用せずに手動で .jar を追加すると、正常に動作します。

これは私が maven で管理する最初のプロジェクトであり、そこからの移行方法がわかりません。ポインタをいただければ幸いです。

投稿リクエストの編集 --- これが私の 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>fr.univnantes.atal.atcal</groupId>
  <artifactId>AtCal</artifactId>
  <version>0.1</version>
  <packaging>jar</packaging>

  <name>AtCal</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <repositories>
    <repository>
      <id>google-api-services</id>
      <url>http://google-api-client-libraries.appspot.com/mavenrepo</url>
    </repository>
  </repositories>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.api-client</groupId>
      <artifactId>google-api-client</artifactId>
      <version>1.12.0-beta</version>
    </dependency>
    <dependency>
      <groupId>com.google.apis</groupId>
      <artifactId>google-api-services-calendar</artifactId>
      <version>v3-rev20-1.12.0-beta</version>
    </dependency>
  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <!-- best lock down version of the plugin too -->
      <configuration>
        <source>1.5</source>
        <target>1.5</target>
      </configuration>
    </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

基本的に、カレンダーと API クライアントの 2 つの依存関係を追加しました。これは、ドキュメントで作業を行うための前述のステップでした。

4

3 に答える 3

14

一見非常にベータgoogle-api-services-calendar:v3-rev20-1.12.0-betaっぽいものはまだ sontaype リポジトリにプッシュされていないようですが、推奨されるリポジトリと Calendar API で言及されているリポジトリの両方を POM に含めようとすると、次のようになります。

<repositories>
    <repository>
        <id>google-api-services</id>
        <url>https://oss.sonatype.org/content/repositories/releases/</url>
    </repository>
    <repository>
        <id>google-api-services-beta</id>
        <url>http://google-api-client-libraries.appspot.com/mavenrepo</url>
    </repository>
</repositories>

また、次の追加の依存関係が必要なようです。

<dependency>
    <groupId>com.google.api-client</groupId>
    <artifactId>google-api-client-java6</artifactId>
    <version>1.12.0-beta</version>
</dependency>
<dependency>
    <groupId>com.google.oauth-client</groupId>
    <artifactId>google-oauth-client-jetty</artifactId>
    <version>1.12.0-beta</version>
</dependency>
<dependency>
    <groupId>com.google.http-client</groupId>
    <artifactId>google-http-client-jackson2</artifactId>
    <version>1.12.0-beta</version>
</dependency>

それが役立つことを願っています。

于 2012-12-01T20:01:41.750 に答える
2

Googleカスタム検索APIで冒険しました。問題のほとんどは、mvn リポジトリhttp://google-api-client-libraries.appspot.com/mavenrepoが利用できないことが原因でした。

から取得したカスタム検索 jar:

<repository>
  <id>google-api-services</id>
  <url>http://mavenrepo.google-api-java-client.googlecode.com/hg</url>
</repository>

手動でダウンロードしたjar内のpomにありました。最新の google-api-clientgoogle-http-client-jackson (1.13.2-beta では、JacksonFactory は追加の依存関係です) は中央の Maven リポジトリにありました。

于 2013-02-05T07:57:32.660 に答える
0

数か月前の時点で、Google はライブラリを Sonatype リポジトリにプッシュし始めました。google-api-client-libraries.appspot.com/mavenrepoまたはを指すpom.xmlにリポジトリエントリを含める必要はなくなりましたmavenrepo.google-api-java-client.googlecode.com

これを行うと、そのリポジトリですべての依存関係 (Google 以外のものも含む) をチェックすることになるため、ビルドが遅くなります。これらは 404 をチェックしてから、マスター リポジトリをチェックします。

于 2013-08-21T15:31:06.380 に答える