SpringBoot热部署
注:会导致spring缓存对象不可用,是类加载器错误导致的
方法1
引入依赖(此方法对于方法、类的新建都能实现热加载,依赖要)
crtl+shift-alt+/
勾上compiler.automake.allow.when.app.running就可以实时热加载,不勾就当build的时候才会加载
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency>
方法2:以maven方式启动mvn spring-boot:run(此方法使用在多模块中,无法启动项目)
在maven plugin中添加springloaded依赖
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>1.3.3.RELEASE</version> <!--spring boot 热部署方法二,以maven方式启动--> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>springloaded</artifactId> <version>1.2.5.RELEASE</version> </dependency> </dependencies> <configuration> <mainClass>com.imooc.DemoApplication</mainClass> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin>
方法3:在Application启动配置中(此方法只能对原来的类的变化实现热情加载,对于新建的类就无法识别)
VM options项加上:
-javaagent:D:\document\maven-dependcies\org\springframework\springloaded\1.2.5.RELEASE\springloaded-1.2.5.RELEASE.jar -noverify
本文来自博客园,作者:咔咔皮卡丘,转载请注明原文链接:https://www.cnblogs.com/anquing/p/17646472.html