简体   繁体   English

eclipse不能在jar中为Google api客户端找到类

[英]eclipse cannot find class in jar for google api client

I have a project that uses google calendar. 我有一个使用Google日历的项目。 I built the original code in a separate project that used maven. 我在使用maven的单独项目中构建了原始代码。

This is the maven artifact: 这是Maven工件:

 <dependency> <groupId>com.google.api-client</groupId> <artifactId>google-api-client</artifactId> <version>1.22.0</version> </dependency> 

Works just fine. 效果很好。

I then import the code into another project that doesn't use maven. 然后,我将代码导入另一个不使用Maven的项目中。 I go to the maven website and download THIS SAME JAR. 我去maven网站并下载THIS SAME JAR。 I go to Project -> Properties -> Build Path -> Add External Jars and add this jar. 我转到Project -> Properties -> Build Path -> Add External Jars jar,然后添加此jar。

I go Project -> Clean and build the project. 我去Project -> Clean并构建项目。

The result? 结果? Classes such as: com.google.api.client.util.store.DataStore and com.google.api.client.util.store.DataStoreFactory 此类: com.google.api.client.util.store.DataStorecom.google.api.client.util.store.DataStoreFactory

CANNOT BE RESOLVED! 无法解决!

I know they are in the jar because I just used it with maven! 我知道他们在罐子里,因为我只是和maven一起使用的!

Any help on this? 有什么帮助吗?

You have this problem because google-api-client requires 您有此问题,因为google-api-client需要

Google HTTP Client Library for Java 适用于Java的Google HTTP客户端库

Google OAuth Client Library for Java 适用于Java的Google OAuth客户端库

You did not face this problem in maven as maven downloaded them for you internally. 您没有在maven中遇到此问题,因为maven在内部为您下载了它们。 Maven resolves transitive dependencies ie (dependencies that are required for your jar) internally. Maven在内部解决传递依赖关系,即(jar所需的依赖关系)。 You did not see that coming. 您没有看到即将到来。

You can download both from here : 您可以从此处下载两者:

google-http-client google-http-client

google-oauth-client google-oauth-client

Have a look at maven's dependency resolution mechanism here 这里看看Maven的依赖解析机制

Have a look here to get idea of the required dependencies for your current api to work: 看一下这里,以了解当前api起作用所需的依赖关系:

https://github.com/google/google-api-java-client/tree/c7421ae143c45b3e75c2bd6dcc86eba0d39bcf59#dependencies https://github.com/google/google-api-java-client/tree/c7421ae143c45b3e75c2bd6dcc86eba0d39bcf59#dependencies

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM