{"id":69992,"date":"2019-01-29T10:02:59","date_gmt":"2019-01-29T10:02:59","guid":{"rendered":"https:\/\/www.whizlabs.com\/blog\/?p=69992"},"modified":"2021-01-12T07:47:31","modified_gmt":"2021-01-12T07:47:31","slug":"spring-framework-5","status":"publish","type":"post","link":"https:\/\/www.whizlabs.com\/blog\/spring-framework-5\/","title":{"rendered":"Introduction to Java Spring Framework 5"},"content":{"rendered":"<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Spring framework is one of the most popular Java frameworks which is used for developing diverse Java applications. It is designed to provide an infrastructure for easy development. It is also marketed as the \u201csource of modern java.\u201d Just like any other framework, it is also updated regularly to keep up with the changing development market.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The latest iteration right now is Spring 5. It is the Spring latest version. In this article, we will explore Spring 5 and provide a basic introduction related to it. This includes going through its major features one by one. This information on Spring Framework 5 will help you a lot if you&#8217;re preparing for <a href=\"https:\/\/www.whizlabs.com\/blog\/spring-professional-certification-preparation\/\" target=\"_blank\" rel=\"noopener\">Spring certification<\/a>. So, let&#8217;s get ahead and learn about Spring Framework 5.\u00a0<\/span><\/p>\n<blockquote><p>Preparing for a Java interview? Go through these top 100 <a href=\"https:\/\/www.whizlabs.com\/blog\/top-java-interview-questions\/\" target=\"_blank\" rel=\"noopener noreferrer\">Java Interview Questions<\/a> and get ready to ace the interview.<\/p><\/blockquote>\n<h2 style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Introduction to Java Spring Framework 5<\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Spring is one of the <a href=\"https:\/\/www.whizlabs.com\/blog\/top-java-frameworks\/\" target=\"_blank\" rel=\"noopener noreferrer\">top Java frameworks<\/a>. Spring Framework 5 was first released in September 2017. The update came after a long time the version 4 was released way back in December 2013.\u00a0<\/span><\/p>\n<p style=\"text-align: justify;\">Spring is versatile in its approach as it offers developers the ability to build applications using \u201cplain old Java objects\u201d which are also known as \u201cPOJOs\u201d. So, how a developer can be benefited with Spring? For example, he can execute a Java method in a database without using transaction APIs but using local Java method as a message handler.<\/p>\n<p style=\"text-align: justify;\">There are many possibilities in which Spring offers better control and is also configurable over vanilla Java.\u00a0It brought a slew of new features and enhancement which we are going to discuss in the following sections.<\/p>\n<h3 style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Important Features of Spring Framework 5\u00a0<\/span><\/h3>\n<p style=\"text-align: justify;\">Spring Framework 5 has come up with some unique features along with compatibility and support. Let&#8217;s check out what are the Spring Framework 5 Features.<\/p>\n<ul>\n<li style=\"text-align: justify;\">\n<h4><span style=\"font-weight: 400;\">JDK Baseline Updates<\/span><\/h4>\n<\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Many baseline updates are pushed to Java Spring Framework 5, the spring latest version. These updates will ensure that Spring 5 works with the latest dependencies and technologies. The initial release saw the non-support for the Java 9 due to the late release date of Java 9. However, now it does support Java 9.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Spring 5 uses Java 8. It means that developers can take advantage of features such as lambda expressions. It also supports Java EE 7 and Java EE 8. As a developer, you can also use Bean Validation 2.0, Servlet 4.0, and JPA 2.2. The older versions are also supported. The Spring 5 update compasses other technologies&#8217; growth as well and supports their latest version to ensure that new features can be used without much hassle.<\/span><\/p>\n<ul>\n<li style=\"text-align: justify;\">\n<h4><span style=\"font-weight: 400;\">Core Framework Revision<\/span><\/h4>\n<\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Spring 5 also saw new core framework updates. The latest updates are pushed so that the Java 8 features can be utilized without any issues. There are many new features, however, only a few of them are worth noticing. They are as follows.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; Method parameters in Spring 5 can be accessed, thanks to the Java 8 reflection enhancements efficiently.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; Core Spring interfaces now provide selective declarations.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; @NotNull and @Nullable are used to annotate nullable fields, arguments, and return values explicitly.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; NIO2 streams are used to do file operations instead of the regular FileInput\/OutPut Stream. By doing so, performance is boosted for applications that utilize a lot of files. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; A new Commons Logging bridge, spring-jcl is used instead of the standard Commons Logging.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; Auto-detect is also turned on for JUL(java.util.logging), SLF4J, Log4j without the need for any extra bridges.<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"text-align: justify;\">\n<h4><span style=\"font-weight: 400;\">Reactive Programming<\/span><\/h4>\n<\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">One of the biggest features that you will see in Spring framework 5 is the adoption of the new programming paradigm. It is based on reactive principles, and you can get a glimpse of what it has to offer in the <\/span><span style=\"font-weight: 400;\">reactive manifesto. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Spring 5 is also compatible with JDK 9 and Java 8 which made it a great pick for anyone who is looking to develop Java with the latest Java version. The game-changer here was reactive streams which made web development an exciting journey for developers. It is a language-neural attempt that will enable developers to define reactive APIs. To ensure that reactive streams can be used effectively, the Reactor is provided. It is a Reactive Streams Java implementation that offers its way to utilize the reactive features and core APIs.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">With reactive programming as its theme, developers are excited as it will allow them to build next-level responsive and resilient services that would scale without any problem; thanks to the use of the new event-loop execution model. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The modules for the new Spring Web Reactive are available through the spring-web-reactive module. To know more, you can refer to a good <a href=\"https:\/\/www.whizlabs.com\/blog\/spring-framework-books\/\" target=\"_blank\" rel=\"noopener\">Spring book<\/a> and learn more about the Spring framework.<\/span><\/p>\n<blockquote><p>Also Read: <a href=\"https:\/\/www.whizlabs.com\/blog\/top-java-frameworks\/\" target=\"_blank\" rel=\"noopener noreferrer\">Top 5 Java Frameworks<\/a><\/p><\/blockquote>\n<ul>\n<li style=\"text-align: justify;\">\n<h4><span style=\"font-weight: 400;\">Functional Web Framework And Kotlin Support<\/span><\/h4>\n<\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Spring Framework 5 also brought support for functional programming. It does it by providing a Functional Web Framework. This way, developers can easily create endpoints using functional programming. The two main components that handle the framework include HandlerFunction and RouterFunction. Each of these two components has their own workload. <\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><b>HandlerFunction: <\/b>It h<span style=\"font-weight: 400;\">andles all the incoming requests and then generates responses.<\/span><\/li>\n<li style=\"font-weight: 400;\"><b>RouterFunction:<\/b><span style=\"font-weight: 400;\"> It is used as an alternative to the @RequestMapping annotation which ensures that the incoming requests are sent to the handler functions.<\/span><\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><b>Example of a RouterFunction<\/b><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">RouterFunction&lt;String&gt; route =<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0route(GET(&#8220;\/World&#8221;),<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0request -&gt; Response.ok().body(fromObject(&#8220;Hello World&#8221;)));<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The functional programming can also be achieved with Kotlin language. It supports functional programming style and also supports the object-oriented paradigm. The Kotlin programming language runs on top of the JVM. Kotlin is extremely useful in enabling functional Spring programming which, in return, helps developers to develop functional web endpoints.<\/span><\/p>\n<pre style=\"text-align: justify;\"><span style=\"font-weight: 400;\">{<\/span>\r\n\r\n<span style=\"font-weight: 400;\">(\"\/movie\" and accept(TEXT_HTML)).nest {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">GET(\"\/\", movieHandler::findAllView)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">GET(\"\/{card}\", movieHandler::findOneView)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">(\"\/api\/movie\" and accept(APPLICATION_JSON)).nest {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">GET(\"\/\", movieApiHandler::findAll)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">GET(\"\/{id}\", movieApiHandler::findOne)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Example of how Kotlin code looks for Web functional API.<\/span><\/p>\n<ul>\n<li style=\"text-align: justify;\">\n<h4><span style=\"font-weight: 400;\">Core Container Updates<\/span><\/h4>\n<\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">There are many core container updates to Spring 5.0. Let\u2019s list them below to get a grasp of the changes.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Candidate component index is supported with the Spring Framework 5 instead of using the classpath scanning.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Loading component index is cheap. This means that the time to load the index will not increase with the increase in the number of classes used. However, the component scan will impact startup time significantly.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Developers can now read entities directly from the index rather than using the classpath scanning method. This will improve performance for projects that utilize less than 200 classes. However, using the method for the larger project means a significant impact.<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Any current project can have its own META-INF\/spring components file during the application building task. <\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Larger projects will start faster due to the above changes. However, it will not be instant, and developers still need to wait for 20-30 minutes before the project loads up.<\/span><\/li>\n<li style=\"text-align: justify;\">\n<h4><span style=\"font-weight: 400;\">Testing Improvements<\/span><\/h4>\n<\/li>\n<\/ul>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Testing has also been improved in Spring 5.0. It includes the update to JUnit 5 Jupiter using JUnit 5. You can use it to write extensions and tests. It also comes with a test engine that offers Jupiter-based tests.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Parallel tests have also been supported. This means that you can run multiple tests using the Spring TestContext Framework. So, you might be thinking how the reactive programming model fits here? Don\u2019t worry as spring-test now uses WebTestClient to support the Spring WebFlux. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The older JUnit 4 is also supported which means that it is not necessary to the use the latest JUnit release.<\/span><\/p>\n<h3 style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Dropped Features in Spring Framework 5\u00a0<\/span><\/h3>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">The new Spring 5.0 introduced support for many frameworks and programming languages. But it also dropped support for many frameworks as well. They are the Protlet, XMLBeans, JDO, JasperReports, Guava, Velocity.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Support has also been dropped for many packages at an API level. Let\u2019s list them below.<\/span><\/p>\n<ul style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">beans.factory.access<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">mock.staticmock<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">jdbc.support.nativejdbc<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">web.view.titles2M<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Orm.hibernate3 and orm.hibernate4.<\/span><\/li>\n<\/ul>\n<blockquote><p>Also Read: <a href=\"https:\/\/www.whizlabs.com\/blog\/core-java-interview-questions\/\" target=\"_blank\" rel=\"noopener noreferrer\">Core Java Interview Questions<\/a><\/p><\/blockquote>\n<h4 style=\"text-align: justify;\"><span style=\"font-weight: 400;\">Final Words<\/span><\/h4>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">This leads us to the end of our Java Spring Framework 5 introduction. We discussed the key features that Spring 5.0 has to offer. The Core Container updates ensure smooth development as it focuses on reducing the time to run a project. Other improvements include the addition of reactive programming paradigm and functional programming as well. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">These features are bound to grow in the near future as we are going to see more macro and micro level updates to the Spring 5.0 Framework. If you are aspired to become a certified Java professional, join our <a href=\"https:\/\/www.whizlabs.com\/oracle-java-certifications\/\" target=\"_blank\" rel=\"noopener noreferrer\">Oracle Java certifications training<\/a> and start your preparation.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400;\">However, Reactive programming will open new opportunities for developers as they can develop more scalable solutions. So, what do you think about Spring Framework 5? Are you going to use it in your projects? Comment below and let us know, we are listening!<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spring framework is one of the most popular Java frameworks which is used for developing diverse Java applications. It is designed to provide an infrastructure for easy development. It is also marketed as the \u201csource of modern java.\u201d Just like any other framework, it is also updated regularly to keep up with the changing development market. The latest iteration right now is Spring 5. It is the Spring latest version. In this article, we will explore Spring 5 and provide a basic introduction related to it. This includes going through its major features one by one. This information on Spring [&hellip;]<\/p>\n","protected":false},"author":220,"featured_media":69994,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[13],"tags":[1728,1751,1752,1753],"class_list":["post-69992","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-java-spring-framework","tag-spring-5-0","tag-spring-framework-5-features","tag-spring-latest-version"],"uagb_featured_image_src":{"full":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2019\/01\/Spring_Framework5.png",600,315,false],"thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2019\/01\/Spring_Framework5-150x150.png",150,150,true],"medium":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2019\/01\/Spring_Framework5-300x158.png",300,158,true],"medium_large":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2019\/01\/Spring_Framework5.png",600,315,false],"large":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2019\/01\/Spring_Framework5.png",600,315,false],"1536x1536":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2019\/01\/Spring_Framework5.png",600,315,false],"2048x2048":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2019\/01\/Spring_Framework5.png",600,315,false],"profile_24":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2019\/01\/Spring_Framework5.png",24,13,false],"profile_48":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2019\/01\/Spring_Framework5.png",48,25,false],"profile_96":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2019\/01\/Spring_Framework5.png",96,50,false],"profile_150":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2019\/01\/Spring_Framework5.png",150,79,false],"profile_300":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2019\/01\/Spring_Framework5.png",300,158,false],"tptn_thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2019\/01\/Spring_Framework5-250x250.png",250,250,true],"web-stories-poster-portrait":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2019\/01\/Spring_Framework5.png",600,315,false],"web-stories-publisher-logo":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2019\/01\/Spring_Framework5.png",96,50,false],"web-stories-thumbnail":["https:\/\/www.whizlabs.com\/blog\/wp-content\/uploads\/2019\/01\/Spring_Framework5.png",150,79,false]},"uagb_author_info":{"display_name":"Aditi Malhotra","author_link":"https:\/\/www.whizlabs.com\/blog\/author\/aditi\/"},"uagb_comment_info":8,"uagb_excerpt":"Spring framework is one of the most popular Java frameworks which is used for developing diverse Java applications. It is designed to provide an infrastructure for easy development. It is also marketed as the \u201csource of modern java.\u201d Just like any other framework, it is also updated regularly to keep up with the changing development&hellip;","_links":{"self":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/69992","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/users\/220"}],"replies":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/comments?post=69992"}],"version-history":[{"count":3,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/69992\/revisions"}],"predecessor-version":[{"id":76831,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/posts\/69992\/revisions\/76831"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/media\/69994"}],"wp:attachment":[{"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/media?parent=69992"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/categories?post=69992"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.whizlabs.com\/blog\/wp-json\/wp\/v2\/tags?post=69992"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}