我正在使用谷歌日历
java API进行项目.
日历部分很好,maven似乎下载并使用它没有任何麻烦.
我的问题来自这个lib的主要依赖:com.google.api.client api.
特别是,当我按照this page中详述的说明操作时,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并手动添加.jar而不使用maven它工作正常.
这是我用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>
我基本上添加了两个依赖项:calendar和api client.这是提到的步骤,让事情在文档上工作.
解决方法
似乎看似非常beta-ish google-api-services-calendar:v3-rev20-1.12.0-beta尚未被推送到sontaype存储库,但是如果你试图同时包含推荐的repo和提到的repo在POM中的Calendar API下:
<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>
希望有所帮助.