Apollo Android客户端-无法访问classpath上生成的类 [英] Apollo Android Client - Cannot access generated classes on classpath

查看:79
本文介绍了Apollo Android客户端-无法访问classpath上生成的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功生成了Apollo类,并且可以在构建目录中看到它们,但是它们在类路径中不可用.奇怪的是,生成的Enum可用,但类本身不可用.

I've generated the Apollo classes successfully and can see them in the build directory, however they're not available on the classpath. Strangely the Enum that is generated is available but the classes themselves aren't.

运行Apollo的Github上提供的示例项目确实可以,但是我看不到配置之间的差异.

Running the sample project provided on Apollo's Github does work but I cant see the difference between the configurations.

下面的mcve.

https://github.com/michaeljq/graphQlMCVE

推荐答案

现在,您有src/main/graphql/包含GraphQL文档.这意味着您的Java类将在没有Java包的情况下生成,这可能不是您想要的.

Right now, you have src/main/graphql/ containing GraphQL documents. That means that your Java classes will be generated with no Java package, which probably is not what you want.

相反,请在src/main/graphql/(例如,src/main/graphql/apollotest/mq/apollotest/api/)下创建一个软件包树.将GraphQL文档和schema.json移到那里.清理项目,然后您应该会发现,无论选择哪种Java包(例如,上例中的apollotest.mq.apollotest.api),都可以使用Apollo生成的类.

Instead, create a package tree under src/main/graphql/ (e.g., src/main/graphql/apollotest/mq/apollotest/api/). Move the GraphQL documents and schema.json there. Clean the project, and you should find that your Apollo-generated classes are available to you in whatever Java package you chose (e.g., apollotest.mq.apollotest.api in the above example).

这篇关于Apollo Android客户端-无法访问classpath上生成的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆