Spring/Hibernate 实体管理 Web 界面/UI

发布于 2024-10-08 03:17:23 字数 673 浏览 0 评论 0原文

我们有一个服务器应用程序,它通过多种协议向特定的客户端 UI 公开特定的模型以及基于该模型构建的一组服务。这是一种服务器应用程序,一旦设置完毕,就不需要太多的手动干预。但是,偶尔(特别是首次部署解决方案时),必须创建和链接某些模型对象。

该解决方案基于 Spring、Spring MVC 和 Hibernate(以及其他)构建,使用 JPA 注释进行 ORM 内容。

我的问题:有谁知道有一个框架可以让我非常快速地设置(最好是纯粹通过配置)一个 Web 界面来管理(CRUD)实体?这不必必须很花哨,并且不需要需要有花哨的安全性(我可以从应用程序服务器内部处理安全性)。然而,它需要能够处理实体之间的复杂关系(集合映射、枚举等)。

例如:应用程序有一个实体 User,该实体具有与之关联的典型角色实体(每个用户有 1 个角色)。目前,在不从头开始创建我们自己的 Web 层的情况下定义这一点的唯一方法是:

  1. 创建 SQL 语句来导入新用户(及其角色)
  2. 拥有某种使用 Spring/Hibernate 配置的脚本(例如使用 Ant)关联并保存新的 Role() 和 User() 对象

显然,如果我们有一个服务器附带的基本 Web 界面(我们不需要自己开发)来处理此类任务(创建、更新、删除、...)。

We have a server application that exposes a certain model, and set of services built on that model, to a particular client UI through a number of protocols. This is the kind of server application where, once it's set-up, there's not much manual intervention required. However, once in a while (particularly when the solution is first deployed), there will have to be some creation and linking of certain model objects.

This solution is built on Spring, Spring MVC and Hibernate (amongst other things) using JPA annotations for the ORM stuff.

My question: does anyone know of a framework that will allow me to very quickly set-up (ideally purely through configuration) a web interface to manage (CRUD) entities? This doesn't have to be fancy, and doesn't need to have fancy security (I can handle security from within the application server). It would however need to be able to handle complex relations between entities (collection mappings, enums, etc.).

For example: the application has an entity User, which has the typical Role entity associated with it (each user has 1 Role). Right now, the only way to define this without creating our own web layer from scratch is:

  1. Create SQL statements to import new users (and their roles)
  2. Have some kind of script (using Ant, for example) that uses the Spring/Hibernate configuration to associate and save a new Role() and User() object

Obviously it would be easier if we had a basic web interface (that we don't need to develop ourselves) that comes with the server to handle these kind of tasks (creating, updating, deleting, ...).

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

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

发布评论

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

评论(5

调妓 2024-10-15 03:17:23

裸对象OpenXavaSpring Roo,都可以满足您的需求。

Naked Objects, OpenXava and Spring Roo, all can do what you are looking for.

眉目亦如画i 2024-10-15 03:17:23

看起来基于 Spring/JPA 的应用程序的LightAdmin 可插入管理界面将是您的不错选择。它具有用于接口配置的内置 Java DSL,您唯一需要做的就是下载 jar 或声明 Maven 依赖项,通过 web.xml 启用域管理(指向包含 JPA 实体的包)并创建 @Administration实体的配置。

下面是一个配置示例:

@Administration( User.class )
public class UserAdministration {

  public static EntityMetadata configuration(EntityMetadataBuilder configurationBuilder ) {
    return configurationBuilder.nameField( "firstname" ).build();
  }

  public static ScreenContext screenContext( ScreenContextBuilder screenContextBuilder ) {
    return screenContextBuilder
           .screenName( "Users Administration" )
           .menuName( "Users" ).build();
  }

  public static FieldSet listView( final FieldSetBuilder fragmentBuilder ) {
    return fragmentBuilder
           .field( "firstname" ).caption( "First Name" )
           .field( "lastname" ).caption( "Last Name" ).build();
  }

Looks like LightAdmin pluggable administration interface for Spring/JPA based applications would be a good choice for you. It has a built-in Java DSL for interface configuration and the only thing you need to do is to download a jar or declare Maven dependency, enable your domain administration through web.xml (point to package containing your JPA entities) and create @Administration configuration for the entity.

Here is an example of configuration:

@Administration( User.class )
public class UserAdministration {

  public static EntityMetadata configuration(EntityMetadataBuilder configurationBuilder ) {
    return configurationBuilder.nameField( "firstname" ).build();
  }

  public static ScreenContext screenContext( ScreenContextBuilder screenContextBuilder ) {
    return screenContextBuilder
           .screenName( "Users Administration" )
           .menuName( "Users" ).build();
  }

  public static FieldSet listView( final FieldSetBuilder fragmentBuilder ) {
    return fragmentBuilder
           .field( "firstname" ).caption( "First Name" )
           .field( "lastname" ).caption( "Last Name" ).build();
  }
你曾走过我的故事 2024-10-15 03:17:23

我会尝试使用 Grails 来做到这一点。它专为快速开发 CRUD Web 应用程序而构建。它基于 Groovy、Spring 和 Hibernate。

I'd try Grails to do this. It's built for fast development of CRUD web applications. It's based on Groovy, Spring, and Hibernate.

你げ笑在眉眼 2024-10-15 03:17:23

为了详细说明@duffymo,Grails 有一个引导机制,您可以在应用程序启动时插入所需的参考数据。您可以编写代码,以便您可以检测引导程序中是否有参考数据,并且仅在需要时插入;一旦完成就可以放手。

它的代码特别优雅,可以检测它运行的环境,如果需要的话,可以在不同的环境中做不同的事情。

最后,如果您使用 Grail 的脚手架机制,它将为您生成默认的 Crud 屏幕。您可以在几分钟内运行 CRUD 操作。

To elaborate on @duffymo , Grails has a bootstrapping mechanism where you can insert the reference data you need on application startup. You can write the code such that you can detect if the reference data in bootstrap and only insert if you need it; its very hands off once its done.

Its particularly elegant in the code can detect the environment in which it is running on do different things in different environments, if you need to.

Finally, if you use Grail's scaffolding machinery, it will generate default Crud screens for you. You can have CRUD operations up in running in literally minutes.

前事休说 2024-10-15 03:17:23

对于 CRUD 屏幕生成,您可以使用Telosys Tools

它允许使用可自定义的 Velocity 模板从现有数据库模型生成 Web 应用程序 CRUD 屏幕:https://sites。 google.com/site/telosystools/

请参阅教程:https://sites.google。 com/site/telosystutorial/(例如,您可以使用 Spring MVC + JPA)

For CRUD screens generation you can use Telosys Tools.

It allows to generate web app CRUD screens from an existing database model with customizable Velocity templates : https://sites.google.com/site/telosystools/

See the tutorials : https://sites.google.com/site/telosystutorial/ (you can use Spring MVC + JPA for example)

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