基于Maven的SpringBoot项目实现热部署
Poblog 08月07日 2017
1.maven导入spring-boot-devtools
pom.xml的配置
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>runtime</scope>
</dependency>
<build> <plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!-- 没有该配置,devtools 不生效 -->
<fork>true</fork>
<addResources>true</addResources>
</configuration>
</plugin>
</plugins>
</build>
idea和浏览器的配置修改
1- Add LiveReload extension in your browser.(可选)
2- Add devtools dependencies to your pom.xml(if it's maven (spring-boot-devtools)).
3- In your intellij IDEA go to: file->settings->build,execution,deployment. Go to ->compiler->build project automatically.
4-In your intellij IDEA: SHIFT+Ctrl+A ->registry-> compiler.automake.allow.when.app.running
maven搜索spring-boot-devtools 相关jar包的导入
file-project structure-Libraries-点击加号-from maven
输入spring-boot-devtools搜索结果添加
2.解决jar包下载慢的问题
IDEA的安装目录下找到./plugins/maven/lib/maven2/目录或者./plugins/maven/lib/maven3/目录 config目录下修改setting.xml
<mirrors>标签下添加
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>