请选择 进入手机版 | 继续访问电脑版
设为首页收藏本站

欣东微医疗技术论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 502|回复: 0

Spring Boot Developer Tools and LiveReload

[复制链接]

134

主题

146

帖子

2168

积分

欣东微

Rank: 7Rank: 7Rank: 7

积分
2168
发表于 2017-12-20 08:22:58 | 显示全部楼层 |阅读模式
                                            转自https://dzone.com/articles/sprin ... ols-and-live-reload

     When we develop web applications with Java, we have to restart the server to pick up all our changes. This kills productivity. Spring Boot Developers Tools provides solutions to automatically pick up changes without a complete server restart. Let's get productive with Spring Boot Developer Tools.
  You Will Learn  
  • How to use Spring Boot Developer Tools
  • What kind of changes Spring Boot Developer Tools picks up automatically
  • How you can use Live Reload to be more productive
  The Problem With Server Restarts  When we develop our applications (web or RESTful API), we want to be able to test our changes quickly.
  Typically, in the Java world, we need to restart the server to pick up changes. Sure, there are plugins like JRebel that help, but you need shell out money for them.
  Restarting a server takes about 1-5 minutes based on the size of the application. A typical developer does 30-40 restarts in a day. I leave it as an exercise in basic math to determine how much time a developer can save if changes are automatically picked up as soon as they're made.
  That's where Spring Boot Developer Tools comes into the picture.
  Adding Spring Boot Developer Tools to your project is very simple. First, add this dependency to your Spring Boot Project pom.xml:
         <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <scope>runtime</scope>
</dependency>







   
   
  
  Second, restart the application.
  You are all set.
  Don't believe me? Go ahead and make a simple change to your controller. You will see that these changes are automatically picked up.
  Note: By default, any entry on the classpath that points to a folder will be monitored for changes.
  Here are few important things to note:
  These folders will not trigger a reload by default
  
  • /META-INF/maven
  • /META-INF/resources
  • /resources
  • /static
  • /public
  • /templates
  You can configure additional folders to scan below:
  application.properties:
         spring.devtools.restart.additional-paths = /path-to-folder







   
   
  
  You can also configure folders to exclude:
         spring.devtools.restart.exclude=static/**,public/**







   
   
  
  Auto Refresh Your Browser With LiveReload  Spring Boot Developer Tools auto-loads the changes to an application. But if you are developing a web application, you would need to refresh the browser to pick up the change.
  LiveReload aims to solve this problem, offering extensions for browsers.
    Once you install the LiveReload plugin for your browser, you will see that the page auto-refreshes when you make a change in your application code.
  Note: LiveReload is a technology in progress! Expect a few problems!
  Next Steps                   
            

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|eastwill.org ( 辽ICP备17018600号

GMT+8, 2018-5-24 04:15 , Processed in 0.047922 second(s), 16 queries , Apc On.

Powered by Eastwill! X3.2

© 2001-2013 Eastwill Inc.

快速回复 返回顶部 返回列表