I'm attempting to learn Spring MVC but have been spoiled by Grails. While I am able to get a basic web application working I was wondering if there were any tools that could do some of the work to create a crud application given a database or hibernate data model? The only one I've found so far is http://www.skywayperspectives.org/portal/web/guest/downloads/overview I'm not sure how to take the generated code and convert it to use either maven or ant for it's build process.
9 回答
Telosys 做这项工作:http ://www.telosys.org
如果您有一个数据库,它将使用它作为模型来生成代码(JPA 实体等)
标准模板包可用于生成具有 CRUD 屏幕的完全可操作的 Web 应用程序
我从未尝试过,但看起来Appfuse Maven 插件 (AMP)允许您通过 Maven 执行此操作。有一个mvn appfuse:gen-model
命令可以从数据库进行逆向工程并mvn appfuse:gen
创建脚手架的其余部分。
我认为您必须在使用 Appfuse Maven 原型之一创建的项目中运行这些。您可以在此处找到快速入门指南进行设置。
Spring Roo也有一些不错的脚手架,但它还没有您正在寻找的数据库的逆向工程。您的持久性对象需要注释为 @RooEntity 对象,然后才能利用该框架的脚手架。
只需按照本教程:https ://sites.google.com/site/telosystutorial/
它将基于 Spring MVC / Spring Data / JPA 生成一个完整的 Web App
看起来,基于 Spring/JPA 的应用程序的LightAdmin 可插拔管理界面对您来说是一个不错的选择。它有一个用于接口配置的内置 Java DSL,您唯一需要做的就是下载一个 jar 或声明 Maven 依赖项,通过 web.xml 启用您的域管理(指向包含您的 JPA 实体的包)并创建 @Administration实体的配置类。
因此,您将拥有一个干净简单的用户界面,用于 CRUD、过滤等。
下面是一个配置示例:
@Administration( Customer.class )
public class CustomerAdministration {
public static EntityMetadata configuration(EntityMetadataBuilder configurationBuilder ) {
return configurationBuilder.nameField( "firstname" ).build();
}
public static ScreenContext screenContext( ScreenContextBuilder screenContextBuilder ) {
return screenContextBuilder
.screenName( "Customers Administration" )
.menuName( "Customers" ).build();
}
public static FieldSet listView( final FieldSetBuilder fragmentBuilder ) {
return fragmentBuilder
.field( "firstname" ).caption( "First Name" )
.field( "lastname" ).caption( "Last Name" ).build();
}
试试弹簧保险丝
我做了同样的搜索。最后看看JBoss Seam。Seam 似乎有一个数据库模式导入并生成必要的后端和前端代码。Spring Roo 接缝与 JBoss Seam 非常相似,只是 Seam 更长,更成熟。
如果你想通过逆向工程学习 Spring MVC,有 minuteproject track REST-SpringMVC
它“智能”对您的数据库模式进行逆向工程,提供
- JPA2
- AO 带弹簧集成
- Spring MVC 和 REST 集成
智能逆向工程意味着您的 Java 实体不必遵循您的数据库约定(例如表 T_USER 可以提供 Java User 类...)
您可以查看crud-rest-gen项目,该项目解释了如何使用crud-maven-plugin生成:
- CRUD休息 API
- API的文档
- AngularJS CRUD 管理 UI
- 如果您使用 Hibernate Envers 审计您的实体,则用于检索审计信息和相关单元测试的Rest API 。
您需要提供的只是包含 JPA 实体的数据模型。
基于 Spring PetClinic 数据模型,提供了许多示例。
看看塞莱里奥。这是模板Angular 2 + PrimeNG + Spring Boot Web 应用程序的链接。
Celerio 是用于数据驱动应用程序的代码生成器工具。它可以反转数据库模式并生成基于 CRUD 的高级应用程序。
以下截屏视频向您展示了预期内容。