{"id":2030,"date":"2015-11-21T10:29:20","date_gmt":"2015-11-21T15:29:20","guid":{"rendered":"http:\/\/springframework.guru\/?p=2030"},"modified":"2019-05-11T14:04:55","modified_gmt":"2019-05-11T18:04:55","slug":"spring-boot-developer-tools","status":"publish","type":"post","link":"https:\/\/springframework.guru\/spring-boot-developer-tools\/","title":{"rendered":"Spring Boot Developer Tools"},"content":{"rendered":"<p>In the <a href=\"https:\/\/spring.io\/blog\/2015\/11\/16\/spring-boot-1-3-0-released\" target=\"_blank\" rel=\"noopener noreferrer\">1.3.0 release of Spring Boot<\/a> and new module is available called Spring Boot Developer Tools. This new Spring Boot module is aimed at improving developer productivity in building Spring Web Applications.<\/p>\n<p>When you&#8217;re developing a web application in Java, or really any programming language,\u00a0a common workflow is to code, compile, deploy, and then test in the browser. In scripting languages, such as PHP, there is no compile \/ deploy phase. The script is evaluated by the server at run time, thus negating the need for a compile \/ deploy phase.<\/p>\n<p>In the world of Java web development, we don&#8217;t have this luxury. Our Java code is compiled down to Java byte code, then deployed to an application server such as Tomcat. The compile, deploy, test phase is a common step in the process of writing software. The longer it takes, the greater the impact it has on your productivity. I&#8217;ve seen this cycle take just a few seconds, to 30 minutes. Yes, 30 minutes! (It was a highly coupled legacy application from the early 90s &#8211; one of the most effing awful developer experiences I&#8217;ve ever encountered!)<\/p>\n<p>For a long time, the <a href=\"https:\/\/grails.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Grails<\/a> community has enjoyed the benefits of automatic class reloading. It&#8217;s such a pleasure coding a Java application, and only needing to save your file to have the code automatically reload in the Tomcat container &#8211; nearly instantly. This is one of the features that drew me to web development with Grails.<\/p>\n<p>This feature has been missing from web development with Spring MVC for a long time. You could use a 3rd party tool such as <a href=\"https:\/\/zeroturnaround.com\/software\/jrebel\/pricing\/\" target=\"_blank\" rel=\"noopener noreferrer\">jRebel<\/a>, but at $475 annually for a license, it&#8217;s an expensive option for those coding outside the enterprise.<\/p>\n<p>In the world of web development with just Spring MVC, this new feature available in Spring Boot Developer Tools has been long overdue. Way way overdue!<\/p>\n<h1>Reloading vs Restarting<\/h1>\n<p>The reloading agent from Grails is now its own project, called <a href=\"https:\/\/github.com\/spring-projects\/spring-loaded\" target=\"_blank\" rel=\"noopener noreferrer\">Spring Loaded<\/a>. This takes a slightly different, but important approach than the one used in Spring Boot Developer Tools. In reloading, the agent reloads the Java class in the JVM. This avoids the need to start the Tomcat container and Spring context. But has some drawbacks. Works great for coding changes in the class itself. But change the package, or add a new class \/ Spring bean, and you still need to restart.<\/p>\n<p>Spring Boot Developer Tools takes a different approach, it does a restart, not a reload. BUT &#8211; under the covers, it is using two class loaders. One for all jar classes in your project, and one for your project classes. Thus on a &#8216;restart&#8217;, only the project classes are reloaded. The 10&#8217;s of thousands of classes contained in jar files in your typical Java Spring project are not reloaded. By doing this, restarting Tomcat and the Spring context become VERY fast. Since the Spring context is being restarted, it addresses issues found with the approach used in Spring Loaded.<\/p>\n<h2>Use with Build Tools<\/h2>\n<p>The automatic restart is triggered when changes on the classpath are detected. Thus if you build with Maven or Gradle class files in the target directory will change and an automatic build will be triggered.<\/p>\n<h2>Use with IDEs<\/h2>\n<p>IntelliJ and Eclipse are the two most popular IDEs for Java development. There are some notable differences in use between the two IDEs.<\/p>\n<p>Eclipse is the foundation for the <a href=\"https:\/\/spring.io\/tools\" target=\"_blank\" rel=\"noopener noreferrer\">Spring Tool Suite<\/a> (aka STS). Development of the Spring Boot Developer Tools seems biased towards STS. Which is to be expected. Both are Pivotal products. An automatic restart in Eclipse is triggered with the save action. In Eclipse, this triggers a recompile of the change classes, which triggers the automatic restart.<\/p>\n<p>With IntelliJ the process is slightly different. IntelliJ does not recompile on save, but unlike Eclipse, it does perform automatic file saves for you. IntelliJ can be <a href=\"http:\/\/stackoverflow.com\/questions\/12744303\/intellij-idea-java-classes-not-auto-compiling-on-save\" target=\"_blank\" rel=\"noopener noreferrer\">configured to compile on save<\/a>, but this gets disabled when an application is running. Thus in IntelliJ, you need to trigger the build manually, which will in turn fire off the automatic restart. So with the extra step, the developer experience in IntelliJ is not quite as smooth.<\/p>\n<p>I prefer the developer experience with Spring Loaded, where the changes made to your *.java files will trigger the automatic restart\/reload. If the Spring Boot Developer Tools had been developed the same way, the developer experience in both IDEs would be the same. Maybe the team developing the Developer Tools had a technical reason for this. Or maybe it was a choice by Pivotal to promote STS on the Eclipse platform.<\/p>\n<p>This is inconvenient, but I&#8217;m not changing IDEs. The last time I tried STS, it was awful. Randomly hanging, or crashing. You just get what you pay for IMHO.<\/p>\n<h1>Live Reload<\/h1>\n<p>Another cool feature of the Spring Boot Developer Tools is the <a href=\"http:\/\/livereload.com\/extensions\/\" target=\"_blank\" rel=\"noopener noreferrer\">Live Reload integration<\/a>. Live Reload is a browser plugin, which will trigger a page reload upon changes to the source. Thus when you change web content, the page in the browser will automatically refresh. Small improvement. But it is nice not clicking refresh in the browser all the time.<\/p>\n<p>Live Reload is advertised to work for Firefox, Chrome, and Safari. I was unable to get the plugin working in Firefox &#8211; it may be currently broken with Firefox. I did get Live Reload working fine with Chrome. I did not try using it with Safari.<\/p>\n\r\n\t<div class=\"df_call_to_action df_content_element cta_round\"  data-cta-class=\"normal\" data-cta-bg-color=\"#D3D3D3\" data-cta-border-color=\"#0F0F0F\">\r\n\t    <div class=\"cta_wrapper\">\r\n\t    \t<div class=\"cta_header\"><h3 style=\"color:#6cb44a !important;\">Free Introduction to Spring Tutorial<\/h3><\/div>\r\n\t\t    <div class=\"cta_content\">Are you new to the Spring Framework? Checkout my Free Introduction to Spring Online Tutorial.<\/div>\r\n\t    <\/div>\r\n\t     \r\n\t    \t<div class=\"cta_button\">\r\n\t<div class=\"btn_warpper position_right\">\r\n\t\t<a class=\" btn btn_s btn_rounded\" href=\"http:\/\/springframework.guru\/introduction-spring-framework-tutorial\/\" title=\"http:\/\/springframework.guru\/introduction-spring-framework-tutorial\/\" target=\"_self\"  data-button-class=\"flat\" data-button-color=\"#6cb44a\" data-button-color-hover=\"#C0C0C0\" data-button-border-color=\"#000000\" data-button-border-color-hover=\"#6cb44a\" data-button-bottom-color=\"#FF8080\" data-button-bottom-color-hover=\"#FF8080\" data-font-color=\"#FFFFFF\" data-font-color-hover=\"#000000\">\r\n\t\t\t\t\t\t\r\n\t\t\t\t<span>Learn More<\/span>\r\n\t\t\t\t\t\t\r\n\t\t<\/a>\r\n\t<\/div>\r\n<\/div>\r\n\t     \r\n\t<\/div>\r\n\n<h1>Remote Development and Debug<\/h1>\n<p>The Spring Boot Developer Tools includes support of doing remote development and debugging. You can configure automatic restarts\u00a0and debugging to a remote server. Kind of a cool thing to do. But I&#8217;m not sure where I would personally ever use this feature. The folks from Pivotal have a little demonstration of this towards\u00a0the end of this <a href=\"https:\/\/www.youtube.com\/watch?v=A70NMxV13TI\" target=\"_blank\" rel=\"noopener noreferrer\">video<\/a>.<\/p>\n<h1>Demonstration of Spring Boot Developer Tools<\/h1>\n<p>I&#8217;ve described how Spring Boot Developer Tools can improve the development workflow and improve your productivity. But a seeing a demonstration is far more effective. I recorded this video to show you the Developer Tools in action.<\/p>\n<div class=\"lyte-wrapper\" style=\"width:640px;max-width:100%;margin:5px auto;\"><div class=\"lyMe\" id=\"WYL_xDB0-4xLqf0\"><div id=\"lyte_xDB0-4xLqf0\" data-src=\"\/\/i.ytimg.com\/vi\/xDB0-4xLqf0\/hqdefault.jpg\" class=\"pL\"><div class=\"tC\"><div class=\"tT\"><\/div><\/div><div class=\"play\"><\/div><div class=\"ctrl\"><div class=\"Lctrl\"><\/div><div class=\"Rctrl\"><\/div><\/div><\/div><noscript><a href=\"https:\/\/youtu.be\/xDB0-4xLqf0\" rel=\"nofollow\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i.ytimg.com\/vi\/xDB0-4xLqf0\/0.jpg\" alt=\"\" width=\"640\" height=\"340\" \/><br \/>Watch this video on YouTube<\/a><\/noscript><\/div><\/div><div class=\"lL\" style=\"max-width:100%;width:640px;margin:5px auto;\"><\/div>\n<h1>Conclusion<\/h1>\n<p>The Spring Boot Developer Tools module brings some great (and long overdue) features to developing applications with Spring. The automatic restart feature will have a positive impact on your productivity in developing web applications. Use of Developer Tools will change how you develop applications, in a good way. This is the initial release, and the time I&#8217;ve spent using the Developer Tools has been short. I saw one quirky thing, but not a show stopper. My impression is the developer tools module is ready for production use. If you&#8217;re using Spring Boot to develop web applications, it&#8217;s time to upgrade to the 1.3.0 release.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the 1.3.0 release of Spring Boot and new module is available called Spring Boot Developer Tools. This new Spring Boot module is aimed at improving developer productivity in building Spring Web Applications. When you&#8217;re developing a web application in Java, or really any programming language,\u00a0a common workflow is to code, compile, deploy, and then [&hellip;]<a href=\"https:\/\/springframework.guru\/spring-boot-developer-tools\/\" class=\"df-link-excerpt\">Continue reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":4575,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Spring Boot Developer Tools in Sprint Boot 1.3.0 #spring #springboot #java","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[104],"tags":[148,40,29,108],"class_list":["post-2030","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spring-boot","tag-developer-tools","tag-spring","tag-spring-boot","tag-spring-mvc"],"jetpack_publicize_connections":[],"aioseo_notices":[],"modified_by":"jt","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/springframework.guru\/wp-content\/uploads\/2018\/06\/NewBannerBOOTSWeb.jpg","jetpack_shortlink":"https:\/\/wp.me\/p5BZrZ-wK","_links":{"self":[{"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/posts\/2030"}],"collection":[{"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/comments?post=2030"}],"version-history":[{"count":4,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/posts\/2030\/revisions"}],"predecessor-version":[{"id":4623,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/posts\/2030\/revisions\/4623"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/media\/4575"}],"wp:attachment":[{"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/media?parent=2030"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/categories?post=2030"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/springframework.guru\/wp-json\/wp\/v2\/tags?post=2030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}