Here I'll show you two ways to implement a hot deployment in a Springboot project built with MAVEN, making deployment incredibly simple, and both in a very simple way.
Hot Deployment Devtools
Add dependencies directly in Pom.xml:
<dependency> <groupid>org.springframework.boot</< Span class= "Hljs-title" >groupid> <artifactid> Spring-boot-devtools</artifactid> <scope>provided</scope> Span class= "hljs-comment" ><!--Optional I did not understand, all said must be true, but I test true,false, do not add all can--<< Span class= "Hljs-title" >optional>true</optional> </DEPENDENCY>
Start with the project main program portal, and then recompile after the change.
springloaded
Add dependencies directly to the Spring-boot plugin in the Pom.xml:
<Plugin><Groupid>org.springframework.boot</Groupid><Artifactid>spring-boot-maven-plugin</Artifactid><Dependencies><!--Spring Hot deployment--<Dependency><Groupid>org.springframework</groupid> <artifactId> Springloaded</artifactid> << Span class= "Hljs-title" >version>1.2.6.release</version > </dependency> </dependencies> <configuration> <mainclass>cn.springboot.mainspringboot</< Span class= "Hljs-title" >mainclass> </configuration> Span class= "Hljs-tag" ></PLUGIN>
Run:
$ mvn clean spring-boot:run
After the change, the compilation can implement the hot deployment
Conclusion
Both of these approaches are actually spring's web site for the spring project of the jar package, coupled with the advantages of Springboot framework embedded server, making the modified project deployment is very simple; When I use these two methods later, I find that the only real thermal deployment is the latter, The former only realizes the hot start, which can be seen from the console log.
Description
- The project uses MAVEN management, otherwise this simple and useful article is not for you
- The first way configuration file changes cannot touch the hot start
- Second way configuration file changes cannot touch the hot deployment, will prompt the error
Two ways to implement a hot deployment based on MAVEN's Springboot project