在 GWT 中添加外部 jar [英] Adding external jar in GWT

查看:18
本文介绍了在 GWT 中添加外部 jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个打包了源代码的 jar 文件.

I have a jar file with source code packed.

我在war/WEB-INF/lib/xxx.jar 中插入jar 添加到构建路径

i inserted the jar in war/WEB-INF/lib/xxx.jar Add to build path

但是当我运行项目时出现错误

but when i run the project i got an error

编辑添加gwt.xml

  <module rename-to='bookmanagementsystem'>

  <inherits name='com.google.gwt.user.User'/>
  <inherits name='com.google.gwt.user.theme.standard.Standard'/>
  <inherits name='com.example.Book'></inherits>
  <entry-point class='com.example.Book.client.Index'/>  
  
</module>

已编辑

我解决了插件无法连接到位于 127.0.0.1:9997 的开发模式服务器

现在我遇到了问题

Loading inherited module 'com.example.book'
         [ERROR] Unable to find 'com/example/book.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
      [ERROR] Line 6: Unexpected exception while processing element 'inherits'

推荐答案

如果您想将外部 jar 包含到 GWT 中,请确保您执行了以下操作

If you want to include external jar to GWT then make sure you did the following

  1. 检查 jar 是否有 .gwt.xml 文件,并且必须指定来源.
  2. 将其添加到 lib 文件夹
  3. 配置构建路径并将 jar 添加到库中
  4. 从 Order and Export 中选择 jar
  5. 在您的 .gwt.xml 文件中继承此模块

例如.如果你在 jar 中有一个名为sample.source"的包,你在 jar 中的 .gwt.xml 文件是Source.gwt.xml",这个 .gwt.xml 文件在sample"文件夹和source"中的类或实体文件夹

Eg. if you have a package in jar named "sample.source" and your .gwt.xml file in jar is "Source.gwt.xml" and this .gwt.xml file in "sample" folder and classes or entities in "source" folder

那么你当前的项目必须继承它.即它必须有以下标签

Then your current project must inherits it. ie it must have the following tag

 <inherits name='sample.Source'/>

例如:jar文件中的src.gwt.xml

Eg : Sorce.gwt.xml in jar file

<module>
 <source path="">
 <include name="**/MyEntity.java"/>
 </source>
</module>

供参考:http://jonathan.lalou.free.fr/?p=1077

For reference :http://jonathan.lalou.free.fr/?p=1077

GWT 不支持客户端序列化,所以尝试使用 RPC 并在服务器中使用 jar 中的这些类,或者您只需复制 jar 包并添加到 gwt 项目的 src.

GWT is not supporting serialization in client side so try to use RPC and use these classes from jar in server or you just copy the packages of jar and add to src of gwt project.

我解决了jar文件必须有java源代码和class文件或者java源代码打包成jar使用的问题.

这篇关于在 GWT 中添加外部 jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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