springboot熱更新
阿新 • • 發佈:2019-02-04
ati 開發 ont XML 熱更新 autowire server 配置文件 group
在代碼開發過程中 經常需要在不重啟項目的情況下 動態更新代碼或者配置文件
下面我們來看看 具體應該怎麽操作
pom.xml
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtool</artifactId> </dependency>
配置文件 application.properties
server.port:8080 url:http://localhost
WebController
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class WebController { @Autowired private Environment env; @RequestMapping("/getUrl") public String test(){ return env.getProperty("url"); } }
以這種方式同樣可以更新代碼
springboot熱更新