且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在一个应用程序中使用一个gwt应用程序的源代码

更新时间:2022-10-26 08:48:57

如果您想将一个项目应用到另一个项目中,那么以下是一些可能的方法: 第一种方法 h1>

如果您使用两个项目作为单独的模块,即 GWT模块,那么你可以为通用代码创建一个包结构,并将条目添加到gwt.xml文件中。

ProjectModule1.gwt.xml

 < source path ='共享/&GT; 

ProjectModule2.gwt.xml

 < source path ='shared'/> 



第二种方法



项目,然后

开发中:


     < inherits name ='com.project2'/ &GT; //同样用于项目1 


  1. 另外,如果你使用eclipse,构建发展之路


制作中:

b $ b

  1. 您需要为这两个项目创建一个jar并添加到classpath中。

但是如果你使用第二种方法,那么这不是一个很好的方法,因为当你想要加载一个project1,然后project2自动加载和不必要的JavaScript将加载,所以更好地使用模块方法,或者创建第三个项目项目1& project2并在两个项目中使用它。


I have two different gwt projects, and want to use classes of one gwt application in to an another module. Is there any way to do that?

I followed the below approach, added below two lines in the second project

   <inherits name="com.yellowbook.mdb.NationalResidential"/>
   <source path='com.yellowbook.mdb' />

but i am getting the following error:

 Unable to find 'com/yellowbook/mdb/NationalResidential.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?

did i miss any thing here?

If you want to use a one project into another one, then following are some of possible ways:

First approach

If you are using two projects as a separate module i.e. GWT Module, then you can create a package structure for common code and add entry into gwt.xml file.

ProjectModule1.gwt.xml

 <source path='shared'/>

ProjectModule2.gwt.xml

 <source path='shared'/>

Second approach

If you created separate project for this, then

In development:

  1. Add module entry in gwt.xml file, i.e.

    <inherits name='com.project2'/> //same for project 1
    

  2. Also if you working with eclipse, then add required project in build path for development

In Production:

  1. You need to create a jar and add to classpath for both the project.

But if you go with second approach, then it is not a very good approach, because when you want to load a project1 then project2 auto load and unnecessary javascript will load, so better to use module approach, or create a third project which has a common code of project1 & project2 and use it in both projects.