springboot项目如何添加热部署
环境jdk1.8、maven3.6、使用工具为idea
1、在pom.xml文件中添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
2、在idea的File==>Settings==>Build,Execution,Deployment==>Compiler==>Build Project automatically勾选
3、idea按住Ctrl+shift+Alt+/,弹出register后找到compiler.automake.allow.when.app.running勾选
4、这是第一次设置这些东西,所以需要重新启动springboot项目
其实,加了devtools这个插件以后,底层是通过两个不同类型的类加载器加载不同的class类,一个是base-classLoader,另外一个是restartLoader。
这样第三方的相关jar就是通过base-classLoader加载,只要我们没有修改第三方的jar,只修改了我们的业务代码就会被restartLoader加载
以上全是个人的学习笔记记录,如果雷同请联系我删除,祝大家学习愉快!