如何将Java Web应用程序转换为Grails? [英] How to convert a Java web application to Grails?

查看:89
本文介绍了如何将Java Web应用程序转换为Grails?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小型的Java Web应用程序,我想将其转换为Grails Web应用程序。我的Java Web应用程序由Servlet,数据库的实体和hibernate以及普通的旧Java对象类组成。那么最好的方法是什么?

解决方案

我大部分同意约书亚。我已经帮助将java web服务移植到Grails的原型。我首先要理解Grails(域类,控制器,服务,过滤器和CommandObject)中的类的作用以及在白板上的映射,这些角色在当前应用程序中是什么。使用hibernate作为数据库层,这个应该很容易移植,许多像类一样的服务可以按原样移动。控制器层面会出现撕裂现象,所以请确保您仔细考虑。

如果您当前的应用程序不能很好地分离职责,您可能会首先考虑在Java空间中重构代码。代码越干净,您就可以重用为Grails服务。


I have a small Java web application built and I'd like to convert this to a Grails web application. My Java web application consists of Servlets, entity and hibernate for the database, and plain old java objects classes. So What's the best way of going about doing this?

解决方案

I agree with Joshua for the most part. I have helped prototyped moving a java web service to Grails. I would first start with understanding the roles of the classes inside Grails (Domain classes, Controllers, Services, Filters, and CommandObject) and mapping on a whiteboard what does those roles in your current application. With hibernate as the database layer, that should be easy to port, and many service like classes can be moved over as-is. The tear up is going to come at the controller level, so make sure you think that through carefully.

You might think about refactoring your code in the Java space first if your current application does not separate responsibilities well. The cleaner your code, the more you can re-use as Grails services.

这篇关于如何将Java Web应用程序转换为Grails?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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