IDEA 工具开发热布署解决方案
- 工具版本:IDEA 2016
- 开发环境:win7,spring boot,spring data,mysql
方案是我在网上搜索来的,做了一些整理,并将自己使用过程中的注意点做个记录,方便自己和他人借鉴。
方案一:spring-boot-devtools
Spring DevTools说明详见 [ Spring DevTools 介绍 ]
具体设置方法如下:
- 添加maven依赖及开启热布署
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<maxAttempts>500</maxAttempts>
</configuration>
</plugin>
</plugins>
</build>
另外,根据自己需要在配置文件中作如下配置:
#添加那个目录的文件需要restart
spring.devtools.restart.additional-paths=src/main/java
#排除那个目录的文件不需要restart
spring.devtools.restart.exclude=static/**,public/**
- 修改IDEA 设置
1、CTRL + SHIFT + A –> 查找make(或build) project automatically –> 选中 (或者:file->settings -> build,Execution,Deployment ->Compiler)
2、Shift+Ctrl+Alt+/ –> 查找Registry –> 找到并勾选compiler.automake.allow.when.app.running
- Chrome禁用缓存
F12(或Ctrl+Shift+J或Ctrl+Shift+I)–> NetWork –> Disable Cache(while DevTools is open)
方案二:springloaded
springloaded的介绍请自行百度啦,这里不写了。
具体设置方法如下:
- 添加maven jar包依赖
<!--spring热部署-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>springloaded</artifactId>
<version>1.2.7.RELEASE</version>
</dependency>
- 设置运行参数
-javaagent:/Users/{filePath}/springloaded-1.2.5.RELEASE.jar -noverify
见图:
- 注意事项
开启了“make(或build) project automatically”,编写代码时会生卡,估计是因为文件有变更经常编译导致的。可以去掉该选项,改为手工编译。
另外若希望自动编译后不用每次都build,可按如下文章进行设置操作:
http://www.mincoder.com/article/2365.shtml
另附maven仓库地址方便自己作个记录:
maven仓库:https://mvnrepository.com/