使用 GWT +推特4j
我正在尝试构建一个简单的 gwt 项目来获取推文并显示它们。服务器将 twitter4j.Tweet 类型的推文传回客户端。 两个模块都导入 twitter4j.Tweet。 但是当我运行时,我收到以下错误: --- 错误:第 37 行:没有可用于 twitter4j.Tweet 类型的源代码;您是否忘记继承所需的模块? 我似乎在继承twitter4j时遇到问题。我见过的所有关于继承 jar 文件的帖子都不清楚如何做到这一点。我知道我必须将继承指令写入 gwt.xml 文件,例如 --- 但如果我尝试 --- 它不起作用。谁能解释一下吗?
在我在网上发现的一篇文章中,有人建议不要继承它,但是: -- 不要将 twitter4j 放入 gwt.xml 中。只需将其添加到您的项目类路径即可。并使所有功能(例如状态更新)都在您的 serviceImpl 中。尝试一下
这让我更加困惑。我已将 jar 文件添加到我的项目库中。但这不起作用 我怀疑我在这里遗漏了一些非常基本的东西,但我完全陷入困境。有类似 GWT 路径的东西吗? 非常感谢您的帮助
I am trying to build a simple gwt project that fetches tweets and displays them.The server passes back the tweets of type twitter4j.Tweet to the client.
Both modules import twitter4j.Tweet.
But when I run I get the following error:
--- ERROR: Line 37: No source code is available for type twitter4j.Tweet; did you forget to inherit a required module?.
I seem to have problems in inheriting twitter4j. All the posts I have seen about inheriting a jar file are not clear about how to do so. I understand I must write an inheritance instruction into gwt.xml file, something like
---
but if I try
---
it does not work. Can anyone please explain?
In a post I found on the Web one person suggested not to inherit it but:
-- Don't put twitter4j to your gwt.xml. Just add it your project class path. and make all functionalities like status updating and all in your serviceImpl. Try
This confuses me even more. I have added the jar file to my project libraries. But it does not work
I suspect I am missing something quite elementary here, but I am totally stuck. Is there something like a GWT path?
Many thanks for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请记住,
client
包中的所有内容都会编译为 JavaScript 并在用户的浏览器中执行。因此,您只能在应用程序的服务器端使用 twitter4j 的类;您必须创建某种轻量级 GWT 可序列化的“代理对象”,以便在客户端和服务器层之间来回传递数据。由于您无法在应用程序的客户端使用 twitter4j,因此您不需要在
.gwt.xml
文件中引用它。相反,您将 twitter4j 添加到您的类路径中,并在服务器端进行所有更新(如问题底部所述)。您确实提到它“不起作用”,但您的问题中没有足够的信息来试图找出原因。Keep in mind that everything in your
client
package is compiled to JavaScript and executed in the user's browser. Thus, you'll only be able to use twitter4j's classes on the server-side of your application; you'll have to create some sort of light-weight GWT-serializable "proxy object" to pass data back and forth between your client and server tiers.Since you can't use twitter4j on the client side of your app, you will not need anything in your
.gwt.xml
file referencing it. Instead, you'll add twitter4j to your classpath and do all your updating on the server side (as mentioned toward the bottom of your question). You do mention that it "does not work," but there's not enough information in your question to try to figure out why.