【linlong】springboot热部署启动配置方法

相信很多it程序员,都在烦恼开发过程中的一些小问题,例如:开发前后端不分离或者分离的项目,改一点点小东西就要重新启动项目,项目大的情况下需要启动很久,花费我们很多的时间。那么小编将在这里给大家带上解决此问题的一个方便插件,启动热部署来解决此烦恼问题。

1. 引入pom依赖

<!--启用热部署-->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>springloaded</artifactId>
    <version>1.2.6.RELEASE</version>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-devtools</artifactId>
    <optional>true</optional>
</dependency>

2.“File” -> “Settings” -> “Build,Execution,Deplyment” -> “Compiler”,选中打勾 “Build project automatically” 

  3.编辑idea热部署配置:

“Shift+Ctrl+Alt+/” ,选择 “Registry” ,选中打勾“compiler.automake.allow.when.app.running”

勾选compiler.document.save.enabled(指定是否启用保存项目响应当文档被更改),并将它们的对应的保存动作延时时间适当缩小,或者使用默认值也可以、延时时间为细节问题,也可以忽略不计。

4.可能出现的常见问题

java.lang.IllegalStateException: Restarter has not been initialized
    

这个报错可能是因为版本号冲突或版本号不对问题导致,解决问题只需将版本号删除即可,因为小编之前遇到过这个问题,所以上面贴的代码依赖中没有版本号。

示例:

<!-- 这里为可能会出现的依赖代码错误示例 -->
<dependency> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-devtools</artifactId> 
    <!--将版本号删掉即可--> 
    <version>1.3.0.RELEASE</version> 
    <optional>true</optional>
</dependency>

完结!

/* * @Author: LinLong * @LastEditors: LinLong * @Description: 上课进度上传 */ import { ref, onMounted, onUnmounted } from 'vue' import { getItem, setItem } from '@/hooks' import { uselearningProgress } from '@/stores' import { updatedLearningProgress } from '@/apiList/learningProgress' const learningProgressStore = uselearningProgress() //学习进度仓库 const currentProgressFile = ref(null) //当前学习进度文件 const heartbeatTime = 30 * 1000 //30秒 let timer = null //时间函数 export function useClassProgress(onBeforeRouteLeave) { //从仓库获取用户点击的课程->项目->任务->文件 learningProgressStore.$subscribe((mutation, state) => { const { currentProgress } = state // console.log('%c--currentProgress-->', 'background:#18C36E;color:#3F4040;', currentProgress) currentProgressFile.value = { classId: currentProgress.classId, courseId: currentProgress.courseId, courseId_text: currentProgress.courseId_text, projectId: currentProgress.pid == 0 ? currentProgress.id : currentProgress.pid, // projectId: currentProgress.id, taskId: currentProgress.pid == 0 ? null : currentProgress.id, pid_text: currentProgress.pid_text, name: currentProgress.name, file: currentProgress.url, userId: getItem('userInfo').id, } // console.log('%c-----state 学习进度------->', 'background:#18C36E;color:#3F4040;', currentProgress) }) //生命周期页面挂载完毕 onMounted(() => { //接收iframe 异步框架消息 window.addEventListener('message', (e) => { if (e.origin.includes('8013')) { const data = e.data setItem('postMessage', data) // console.log('%c-----监听postMessage子级------->', 'background:#18C36E;color:#3F4040;', JSON.parse(data)) } }) //浏览器tab标签切换或最小化事件设置暂停提交 上课记录 document.addEventListener('visibilitychange', () => { if (document.visibilityState === 'hidden') { timer ? clearTimeout(timer) : (timer = null) //清除定时器 } else if (document.visibilityState === 'visible') { timer ? clearTimeout(timer) : (timer = null) //先清除一次定时器 sendMessage() //继续发送学习进度 } }) //发送统计信息至后端 sendMessage() function sendMessage() { console.log('%c---对方水电费水电费水电费->', 'background:#18C36E;color:#3F4040;') timer ? clearTimeout(timer) : (timer = false) //先清除一次定时器 timer = setTimeout(() => { const sendData = { ...getItem('postMessage'), ...currentProgressFile.value, } // console.log('%c------准备发送的信息sendData------>', 'background:#18C36E;color:#3F4040;', sendData) updatedLearningProgress(sendData).then((res) => { if (res.success) sendMessage() }) }, heartbeatTime) //heartbeatTime } }) //生命周期页面销毁之前 onUnmounted(() => { clearTimeout(timer) // //路由离开 // onBeforeRouteLeave(() => { // clearTimeout(timer) // }) }) }
04-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Java程序猿张某人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值