在GWT项目中继承外部Java源代码 [英] Inherit external java source in GWT project

查看:242
本文介绍了在GWT项目中继承外部Java源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在服务器端使用的ENUM。
我希望可以巧妙地在客户端(GWT)使用这个枚举。



这是结构:

  se.mycompany.core 
se.mycompany.core.TheEnum< - this Enum。

se.mycomapny.web.gwtproject< - GWT项目。
se.mycomapny.web.gwtproject.client

我试着添加

 < inherits name =se.mycompany.core.TheEnum/> 

添加到我的gwtproject.gwt.xml文件中。但是,我收到以下错误消息:

[p] [错误]无法在您的类路径中找到'se / mycompany / core / TheEnum.gwt.xml';可能是一个错字,或者你忘了为源代码包含类路径条目?

我试图将文件TheEnum.gwt.xml添加到'se / mycompany /核心/'与以下上下文。

 < module> 
<继承了name ='com.google.gwt.user.User'/>
< source path =TheEnum>< / source>
< / module>

但它仍抱怨同样的事情。



我猜我需要将se.mycompany.core.TheEnum添加到build.xml中的类路径中,但我不知道如何或在哪里。

inherits标记用于导入其他模块,而不是单个类。您可以通过在核心包下创建一个简单的GWT模块,然后在现有模块中继承该模块来达到目的:



在包 se.mycompany.core 下使用以下命令创建名为 Core.gwt.xml 的文件内容:

 <?xml version =1.0encoding =UTF-8?> 
< module>
< source path =includes =TheEnum.java/>
< / module>

然后在您现有的模块中添加:

 < inherits name ='se.mycompany.core.Core'/> 


I have an ENUM that is used on the server-side. I want to be ably to use this enum on the client side (GWT) aswell.

This is the structure:

se.mycompany.core
se.mycompany.core.TheEnum <-- this Enum.

se.mycomapny.web.gwtproject <-- The GWT project.
se.mycomapny.web.gwtproject.client

I have tried to add

<inherits name="se.mycompany.core.TheEnum"/>

to my gwtproject.gwt.xml file. But I get the following error message:

[ERROR] Unable to find 'se/mycompany/core/TheEnum.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?

I have tried to add the file TheEnum.gwt.xml to 'se/mycompany/core/' with the following context.

<module>
  <inherits name='com.google.gwt.user.User'/>
  <source path="TheEnum"></source>
</module> 

But it still complains about the same thing.

I'm guessing I need to add the se.mycompany.core.TheEnum to the classpath in build.xml somehow, but I dont know how or where.

解决方案

The "inherits" tag is used to import other modules, not individual classes. You could achieve what you want by creating a simple GWT module under the core package, and then inherit that module in the existing one:

Create a file called Core.gwt.xml under package se.mycompany.core with the following content:

<?xml version="1.0" encoding="UTF-8"?>
<module>
    <source path="" includes="TheEnum.java"/>    
</module>

Then in your existing module add:

<inherits name='se.mycompany.core.Core'/>

这篇关于在GWT项目中继承外部Java源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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