Five Things You Need to Know About Spring Framework 5

    This week, immediately after the release of Java 9 , a new major version of one of the most popular frameworks for developing applications in Java - Spring Framework version 5 was released . Under cat details and a brief description of what has changed.


    Java 9 support


    As expected, the new Spring feels quite comfortable working on the new version of Java. This means that the new version of Spring will work both included in the classpath and in the module path (using automatic modules ). The assembly and all the tests of the framework itself work on the new JDK9 (although by default they still use JDK8).


    Reactivity


    The new version of the framework adds a new project to the Spring piggy bank - Spring Reactive Web Framework or WebFlux . This is a completely asynchronous and non-blocking web framework designed to work on top of the event loop , as an alternative to traditional servlets running on top of the classic thread pool.


    Moreover, since the new reactive web is not a development, but rather a parallel direction with Spring MVC , it allows you to work outside of servlet containers and even create minimal microframework-like applications - using a functional approach with WebFlux.fn .


    Kotlin Support


    Kotlin is now not only the officially supported Google language for development on Andriod, but also the officially supported Spring language for backend development.


    Kotlin support includes several aspects at once:


    • Functional Kotlin DSL for describing application components (beans) and WebFlux routes
    • Support Kotlin Script as a view engine using ScriptTemplateView
    • Support for immutable classes, optional parameters, default values, and much more
    • Ability to create a new project using Spring Initializr on Kotlin

    It’s a fact to appreciate the scale and seriousness - there is already more code on Kotlin in the Spring kernel than on Groovy.


    New Documentation


    The official documentation has been restructured and broken down into small modules grouped by functionality.


    Other changes


    There are a lot of them, but several key ones can be distinguished:


    • Null-safety using JSR-305 annotations. Kotlin can work with these annotations, and Java code analysis tools (for example, IDEA understands them, just like FindBugs)
    • Compatible with Java EE 8 - Servlet 4.0, Bean Validation 2.0, JPA 2.2, JSON Binding API 1.0, Tomcat 9.0, Hibernate Validator 6.0
    • Functional registration of components (beans) or WebFlux.fn - now DI can be configured not only through annotations and XML, but simply by code, referring directly to the application context
    • The new common logging bridge is spring-jcl (which automatically knows how to work with Log4j 2.x, SLF4J, java.util.logging)
    • Improvements in the test framework - support for JUnit 5 , parallel execution of tests

    Conclusion


    In general, there are a lot of changes, the new framework is the result of several years of work on the project. You can try the new Spring 5 using either Spring Boot 2.0 build snapshot or the version of M5 that will be released next week. The final version of Spring Boot 2.0 is expected towards the end of this year.


    Useful links:


    Only registered users can participate in the survey. Please come in.

    What version of Spring are you using?

    • 0.6% Spring 2 and below 3
    • 5.6% Spring 3 25
    • 46.9% Spring 4 and Spring Boot 206
    • 24.8% Spring 4 but without Spring Boot 109
    • 9.5% Already updated on Spring 5! 42
    • 12.3% Other (other frameworks, without frameworks, etc.) 54

    Also popular now: