类似 Django 的 Java 框架

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2227338/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 04:58:11  来源:igfitidea点击:

Django like framework for Java

javadjangoframeworks

提问by user267067

I am a Java developer. Is there some Django/Ruby-on-Rails kind of framework for Java? I don't like to create the admin panel for each project I do. It's boring to do the same thing again and again. Also for my new project I have a short deadline and I would like to use some kind of Java framework that speeds up development.

我是一名 Java 开发人员。是否有一些 Django/Ruby-on-Rails 类的 Java 框架?我不喜欢为我所做的每个项目创建管理面板。一遍又一遍地做同样的事情很无聊。同样对于我的新项目,我的截止日期很短,我想使用某种 Java 框架来加快开发速度。

采纳答案by Jens

Recently I found a framework which looked very much like django. It's called playframework and you can find it here:

最近我发现了一个非常像 django 的框架。它叫做 playframework,你可以在这里找到它:

http://playframework.org/

http://playframework.org/

I suggest you watch the video on the front page.

我建议您观看首页上的视频。

Another Java based django-like framework is Spring Roo, but in my opinion it's not quite ready. Last time I used it the documentation was virtually non-existent.

另一个基于 Java 的类似 django 的框架是 Spring Roo,但在我看来它还没有完全准备好。上次我使用它时,文档几乎不存在。

http://www.springsource.org/roo

http://www.springsource.org/roo

回答by Jon

Look into Grails:

看看Grails:

http://www.grails.org/

http://www.grails.org/

回答by Shuwaiee

Django can be run in jvm using jython, more information here http://docs.djangoproject.com/en/dev/howto/jython/

Django 可以使用 jython 在 jvm 中运行,更多信息在这里http://docs.djangoproject.com/en/dev/howto/jython/

回答by Stephen C

Also for my new project i have a short deadline and i would like to use some kind of java framework that speeds development.

同样对于我的新项目,我的截止日期很短,我想使用某种可以加快开发速度的 Java 框架。

I would be cautious about doing a project with a short deadline using a framework that I am not familiar with. It sounds like a recipe for deadline overruns. Stick with technology that you are already familiar with ... and wait for a project with more relaxed deadlines where you can afford the time to make a few mistakes.

我会谨慎地使用我不熟悉的框架来做一个期限很短的项目。这听起来像是超限期限的秘诀。坚持使用您已经熟悉的技术......并等待一个期限更宽松的项目,在那里您可以有时间犯一些错误。

回答by max-dev

Take a look at LightAdmin pluggable administration interfacefor Spring/JPA-backed web applications.

查看用于 Spring/JPA 支持的 Web 应用程序的LightAdmin 可插拔管理界面

Usually, in web application development, you need to have some kind of administration back-end with usable UI and it's boring to develop it from scratch all the time and maintain it in the future.

通常,在 Web 应用程序开发中,您需要具有某种具有可用 UI 的管理后端,并且一直从头开发并在将来维护它很无聊。

Personally, I solved this for my Java projects by simply plugging LightAdminlibrary and doing some customizations from DSL configurations.

就我个人而言,我通过简单地插入LightAdmin库并从 DSL 配置中进行一些自定义来为我的 Java 项目解决了这个问题。

All you need to do is to declare Maven dependency & enable administration panel in your web.xml. Right after this you'll have a feature-rich UI with complete CRUD support, filtering, scopes, security, etc.

您需要做的就是在 web.xml 中声明 Maven 依赖项并启用管理面板。在此之后,您将拥有一个功能丰富的 UI,其中包含完整的 CRUD 支持、过滤、范围、安全性等。

LightAdmin's DSL for admin panel customization example:

LightAdmin用于管理面板自定义示例的 DSL:

@Administration( Booking.class )
public class BookingAdministration {

public static ScopesConfigurationUnit scopes( final ScopesConfigurationUnitBuilder scopeBuilder ) {
    return scopeBuilder
        .scope( "All", all() )
        .scope( "Smoking Apartments", specification( smokingApartmentsSpec( true ) ) )
        .scope( "Non Smoking Apartments", specification( smokingApartmentsSpec( false ) ) )
        .scope( "Long-term bookings", filter( longTermBookingPredicate() ) ).defaultScope().build();
}

public static FiltersConfigurationUnit filters( final FiltersConfigurationUnitBuilder filterBuilder ) {
    return filterBuilder
        .filter( "Customer", "user" )
        .filter( "Booked Hotel", "hotel" )
        .filter( "Check-In Date", "checkinDate" ).build();
}

public static FieldSetConfigurationUnit listView( final FieldSetConfigurationUnitBuilder fragmentBuilder ) {
    return fragmentBuilder
        .field( "user" ).caption( "Customer" )
        .field( "hotel" ).caption( "Hotel" )
        .field( "checkinDate" ).caption( "Check-In Date" )
        .field( "smoking" ).caption( "Smoking" )
        .field( "beds" ).caption( "Beds" )
        .build();
}

public static DomainTypePredicate<Booking> longTermBookingPredicate() {
    return new DomainTypePredicate<Booking>() {
        @Override
        public boolean apply( final Booking booking ) {
            return booking.getNights() > 20;
        }
    };
}

public static DomainTypeSpecification<Booking> smokingApartmentsSpec( final boolean isSmokingApartment ) {
    return new DomainTypeSpecification<Booking>() {
        @Override
        public Predicate toPredicate( final Root<Booking> root, final CriteriaQuery<?> query, final CriteriaBuilder cb ) {
            return cb.equal( root.get( "smoking" ), isSmokingApartment );
        }
    };
}

}

回答by Ahmed Hammad

Have a look at JHipster. Why is it good?

看看 JHipster。为什么好?

  • Generate bootstrap based GUI interface.
  • Client side code generated is base on nodejs and AngularJs
  • Server side code generated is based on Spring boot
  • Unit test and integration tests are automatically generated.
  • You have a wide range of choices regarding client side and server side frameworks.
  • 生成基于引导程序的 GUI 界面。
  • 生成的客户端代码基于 nodejs 和 AngularJs
  • 生成的服务端代码基于Spring boot
  • 单元测试和集成测试是自动生成的。
  • 关于客户端和服务器端框架,您有多种选择。

These points mean, you will build your development on state of the art toolset and frameworks. JHipster is much more than this, have a look at: https://jhipster.github.io/

这些要点意味着,您将在最先进的工具集和框架上进行开发。JHipster 远不止这些,看看:https://jhipster.github.io/

回答by Mihai Tudor Popescu

You can try also Spring Framework or Play Framework, if you want to code in Java for the Web. To generate the GUI, you can use Vaadin

如果您想使用 Java 为 Web 编写代码,您也可以尝试使用 Spring Framework 或 Play Framework。要生成 GUI,您可以使用 Vaadin

Here are some of my sample projects in Spring (I've used only Spring so far and it seems to work well for what I want to do):

以下是我在 Spring 中的一些示例项目(到目前为止我只使用了 Spring,它似乎对我想做的事情很有效):

You can also automatically generate getters/setters based on the fields you have in your classes using Project Lombok. I use that too in my projects, it helps me to write less code and focus on the main problems I have to solve using my coding skills (If I want to add custom code in the methods I generated automatically, I can write them later as I need).

您还可以使用Project Lombok根据类中的字段自动生成 getter/setter 。我在我的项目中也使用它,它帮助我编写更少的代码并专注于我必须使用我的编码技能解决的主要问题(如果我想在我自动生成的方法中添加自定义代码,我可以稍后将它们编写为我需要)。