GWT 和 Spring 集成

发布于 2024-11-29 10:50:03 字数 647 浏览 0 评论 0原文

我目前正在制定一个 Web 应用程序规范,其中包含一个管理界面和一组将由合作伙伴网站使用的 Web 服务。

我一直在使用 GWT,它似乎非常适合管理界面,但同时,我很想使用 Spring 框架来生成应用程序公开的基于 REST 的 Web 服务 API。

我的计划是创建两个独立的 Web 应用程序,一个用于管理员,一个用于 Web 服务。一个是为 Spring 设置的,另一个是使用 GWT 应用程序设置的。显然,我希望在两个应用程序之间共享域模型,我猜这应该是相当简单的任务?我只是想保持简单,在 GWT 客户端项目中实现完整的域模型,并简单地设置 Web 服务的源路径以包含 GWT 项目中相关文件夹中的域模型。

现在,回答我的问题。我确信有人做过类似的事情,在开始之前我应该​​意识到任何潜在的陷阱吗?

我为这个项目留出了相当多的时间,但我之前从未真正使用过 GWT 来处理任何“严肃的”事情,我只是出于个人兴趣而使用它,而且我在 Swing 和 Android UI 开发方面都有相当丰富的经验,所以我相信我可以将它用于(非常简单的)用户界面。这个等式中的“未知”是域模型的共享。我无法想象这是一个问题,因为域模型只是 POJO 的(使用 JDBC,但同样,我真的无法想象这是一个问题)。

另外,是否有比简单地分离 Web 应用程序并共享其域模型更好的方法来集成 GWT 和 Spring?

I'm currently working on a specification for a web application which consist of a administration interface, and a set of web-services which will be consumed by parter websites.

I been playing around with GWT and it seems like an amazing fit for the administration interface, but at the same time, I would love to use the Spring framework to produce the REST based web-service API exposed by the application.

My plan is to create two separate web applications, one for the admin and one for the web-services. One set up for spring and the other with the GWT app. Obviously, I wish to share the domain model between the two applications, I'm guessing this should be fairly trivial to accomplish? I'm thinking just to keep it simple, implement the full domain model in the GWT client project, and simply setting the sourcepath of the web-service to include the domain model from the relevant folders in the GWT project.

Now, to my question. I'm sure somebody out there have done something similar to this, are there any potential pitfalls I should be aware of before starting out?

I got a fair amount of time set aside for this project, but I never actually used GWT before for anything "serious" I just played around with it out of personal interest and I'm fairly experienced in both Swing and Android UI development, so I'm confident I can mange to use it for the (very simple) UI. The "unknown" in this equation is sharing of a domain model. I cant imagine this being a problem, since the domain model will be just POJO's (using JDBC, but again, I cant really imagine this being a problem).

Also, are there better ways of integrating GWT and Spring than simply doing to separate web applications and sharing their domain model?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

素染倾城色 2024-12-06 10:50:03

为什么要创建两个单独的应用程序?
创建一个具有明确分离的应用程序服务层。通过标准 Spring 注释将这些服务公开为 Web 服务,并通过 GWT requestfactory 公开对此服务的访问(不幸的是,据我所知,目前 requestfactory 不能很好地处理 REST 请求,主要是因为它们的序列化方式)。这种方法导致您的应用程序只有一个入口(外观),并允许以两种不同的方式使用该外观。

我参与过几个 GWT+Spring 项目 - 标准案例开发速度非常快,框架集成得非常好。但是,如果您想做一些定制,例如引入基于 spring security 的安全性 - 您将需要进行一些修改,例如覆盖传输类。当然这需要一些时间,但结果非常好。

我绝对会推荐看一下 Spring ROO 示例应用程序(据我所知,roo 部分是由 google 人员开发的)。

Why do you want to create two separate applications?
Create one, with a clearly separated application services tier. Expose this services via standard Spring annotations as webservices, and also expose access to this services via GWT requestfactory (unfortunately, as far as I know, currently requestfactory does not play nice with REST requests, mainly because their way of serialization). This approach results in only one entrance (facade) to your application and allows to use this facade in two different ways.

I've worked on several GWT+Spring projects - for standard cases development goes very fast, frameworks integrates very well. However, if you want to do some customization, e.g. introduce security based on spring security - you will need to do some hacks, such as overriding transport classes. Of course it takes some time, but results are very nice.

I would definitely recommend to take a look at Spring ROO sample applications (as far as I know, roo is partially developed by google guys).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文