简体   繁体   English

GWT:将客户端和服务器端分为不同的WAR

[英]GWT: Separate client- and server-sides into different WARs

I am planning on building a GWT app that will be deployed to GAE. 我正计划构建一个将部署到GAE的GWT应用程序。 In addition to the normal (GWT) web client, the server-side code will service requests from other clients besides just the web app. 除了普通(GWT)Web客户端外,服务器端代码还将为Web应用程序之外的其他客户端请求提供服务。 Specifically, it will host a RESTful API that can be hit from any HTTP-compliant client, and it will also service requests from native apps on iOS and Android. 具体来说,它将托管可从任何HTTP兼容客户端访问的RESTful API,还将为来自iOS和Android的本机应用程序的请求提供服务。

If my understanding of GWT is correct, it's your job to code up both the client-side code (which includes the AJAX requests your app makes back to the server) as well as the server-side request handlers. 如果我 GWT的理解是正确的,那么您既要编写客户端代码(包括应用程序向服务器返回的AJAX请求),也要编写服务器端请求处理程序。

This got me thinking: why do I need to package the web client and the web server inside the same WAR? 这让我开始思考:为什么我需要将Web客户端和Web服务器打包在同一WAR中? This forces me to (essentially) re-deploy the client-side code every time I want to make a change to the backend. 每次我想对后端进行更改时,这迫使我(基本上)重新部署客户端代码。 Probably not a big deal, but if I don't have to, I'd prefer to honor "separation of concerns". 也许没什么大不了的,但是如果我没有必要,我宁愿兑现“关注点分离”。

So I ask: is there a way to essentially deploy a Java-less WAR on GAE in such a way that it just serves pure HTML/JS/CSS back to any clients that will use it, and to then deploy the server-side in its own WAR, and some how link the two up? 因此,我想问:是否有一种方法可以在GAE上基本上部署无Java的WAR,使其仅将纯HTML / JS / CSS提供给将要使用它的任何客户端,然后在服务器端部署它自己的WAR,有些如何将两者联系起来? Thanks in advance! 提前致谢!

The WAR is just for the server side. WAR仅用于服务器端。 It includes the client-side classes needed for serializing objects passed between client and server: obviously, both sides need implementations of the same objects in order to handle those objects. 它包括序列化在客户端和服务器之间传递的对象所需的客户端类:显然,双方都需要相同对象的实现才能处理这些对象。

I don't think it will save you any effort or development time to separate the two concerns, but if you really want to, then you can rework your client/server interaction using something other than GWT-RPC. 我认为分离这两个问题不会节省您的精力或开发时间,但是如果您确实愿意,则可以使用GWT-RPC以外的方法来重新进行客户端/服务器交互。 For example, JSON. 例如,JSON。 See https://developers.google.com/web-toolkit/doc/latest/DevGuideServerCommunication#DevGuideHttpRequests for discussion of your options if you want to go down that road. 如果您想走这条路,请参阅https://developers.google.com/web-toolkit/doc/latest/DevGuideServerCommunication#DevGuideHttpRequests以获取有关您的选择的讨论。

不,AFAIK,您不能在GAE中进行部分更新,即您不能将项目的一部分上载到GAE实例,然后再单独上载另一个部分(从而将HTNML / JS / CSS分离到Java类)。

Hopefully this is what you are looking for. 希望是您想要的。

Finally the main stub that you want to deploy might be EAR file which you can mention in main pom.xml 最后,您要部署的主存根可能是EAR文件,您可以在main pom.xml中提及

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android客户端-Java服务器应用程序 - Android Client- Java Server application GWT客户端和服务器的不同接口实现 - GWT different interface implementation for client and server 在服务器端和客户端具有不同的WAR并将它们部署在不同的应用程序服务器中的利弊 - Pros and Cons of having different WARs for server and client side and deploying them in different application servers 在具有不同弹簧的单个tomcat服务器上进行多次战争 - multiple wars on a single tomcat server with different spring RMI客户端-服务器:java.rmi.ConnectIOException:建立JRMP连接期间出错 - RMI Client- Server: java.rmi.ConnectIOException: error during JRMP connection establishment gwt客户端和gwt服务器的Java公共库 - java common lib for gwt client and gwt server 客户端=&gt;与Vaadin + GWT的服务器通信 - Client => Server communication with Vaadin + GWT GWT服务器&lt;-&gt;客户端消息总线? - GWT server<->client message bus? 无论您是在客户端还是在服务器端,如何为GWT提供2种不同的代码实现 - How can I have 2 different code implementations for GWT whether you're on the client or on the server side Sonar Web客户端-更新值失败 - Sonar web client- Updating a value fails
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM