spring-boot-devtools 能够动态编译java类。好比在开发过程当中,修改了某个java类,可是重启须要好长时间,这个时候用devtools能很快编译好修改的java代码,实现热部署java
使用:web
pom依赖:spring
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.1.0.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!--开发工具--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
启动类和接口:app
@RestController @EnableAutoConfiguration public class HelloWorldApp { @RequestMapping("/") String home() { return "Hello World"; } public static void main(String[] args) throws Exception { SpringApplication.run(HelloWorldApp.class, args); } }
启动后访问 localhost:8080maven
Hello World
修改 home() 方法:ide
@RequestMapping("/") String home() { return "Hello World update"; }
在开发ide的菜单,点击Build->Recompile
从新编译,编译成功后,访问localhost:8080spring-boot
Hello World update