在 Maven GWT 项目中使用 Guava
我有一个项目想要利用 Google Guava 库(在服务器端和客户端),但是,我在设置它时遇到了麻烦。
我能够添加 GWT 和 Guava 作为依赖项,并且我的 GWT 项目正在正确编译。我使用 Guava 的服务器端代码也可以正常工作。
但是,如果我尝试使用以下
<inherits name="com.google.common.collect.Collect" />
命令将其添加到我的 GWT 项目中:并通过 mvn gwt:run 在开发模式下使用应用程序,它会打开 Google 开发模式界面并给出以下错误:
Unable to find 'com/google/common/collect/Collect.gwt.xml' on your classpath...
大概是因为 Maven 依赖项只是编译后的类文件,而不是它需要编译为 Javascript 的 source/.gwt.xml 文件。我发现,如果我访问 guava 网站并下载文件,就会有一个名为 guava-r08-gwt.jar 的文件,我认为该文件正朝着解决方案的方向发展。
理想情况下,我可以在 Maven 中添加一些依赖项,只允许我使用继承命令,但任何其他解决方法都会受到欢迎。
正如其中一个答案中提到的,这是正在进行中的。
与此同时,我为此目的建立了一个临时的公共 maven-repo。我不保证它能保持正常运行,但这里是存储库/依赖项:
<repository>
<id>deepthought</id>
<name>Deepthought Public Repository</name>
<url>http://deepthought.co/maven-repo</url>
</repository>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-gwt</artifactId>
<version>r08</version>
</dependency>
不过,现在请随意使用它。
I have a project which would like to utilize the Google Guava libraries (on both the server-side and the client-side), however, I am having trouble setting it up.
I was able to add GWT and Guava as dependencies, and my GWT projects are compiling correctly. My server-side code using Guava also works correctly.
But if I try to add it to my GWT project using the following:
<inherits name="com.google.common.collect.Collect" />
And use the application in development mode via mvn gwt:run
, it brings up the Google Development Mode interface and gives errors of the flavor:
Unable to find 'com/google/common/collect/Collect.gwt.xml' on your classpath...
Presumably because the maven dependency is just the compiled class files, and not the source/.gwt.xml files it needs to compile down to the Javascript. I found that if I go to the guava website, and download the files, there is a file called guava-r08-gwt.jar, which I think is heading in the direction of a solution.
Ideally, there would be some dependency I could add in Maven that just lets me use the inherits command, but any other workarounds would be welcomed.
As mentioned in one of the answers, this is in the works.
In the meantime, I have set up a temporary public maven-repo for this purpose. I make no guarantees about it staying up, but here is the repo/dependency stuff:
<repository>
<id>deepthought</id>
<name>Deepthought Public Repository</name>
<url>http://deepthought.co/maven-repo</url>
</repository>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-gwt</artifactId>
<version>r08</version>
</dependency>
Feel free to use it for now, though.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它正在制作中。
http://code.google.com/p/guava-libraries /问题/详细信息?id=501
It's in the works.
http://code.google.com/p/guava-libraries/issues/detail?id=501