Revert "本地代码自动编译"

This reverts commit 1647e0ce13.
This commit is contained in:
冯辉
2026-06-27 16:33:21 +08:00
parent 1647e0ce13
commit d0fdbb6c1c
4 changed files with 1 additions and 105 deletions

View File

@@ -1,24 +0,0 @@
package com.ruoyi.web.core.config;
import org.apache.catalina.connector.Connector;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
/**
* DevTools 热重启配置 - 修复 Windows 下端口未释放问题
* 启用 SO_REUSEADDR允许 DevTools 重启时立即复用端口
* 仅在本地开发环境生效,不影响线上
*/
@Profile("local")
@Configuration
public class DevToolsConfig implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> {
@Override
public void customize(TomcatServletWebServerFactory factory) {
factory.addConnectorCustomizers((Connector connector) -> {
connector.setProperty("socket.soReuseAddress", "true");
});
}
}

View File

@@ -2,8 +2,6 @@
server:
# 服务器的HTTP端口默认为8080
port: 9091
# 优雅关闭,防止 Windows 下 DevTools 重启时端口冲突
shutdown: graceful
servlet:
# 应用的访问路径
context-path: /
@@ -52,11 +50,6 @@ spring:
restart:
# 热部署开关
enabled: true
# 变更检测后的静默期ms给 IDE 编译留时间
quiet-period: 400
lifecycle:
# 优雅关闭超时
timeout-per-shutdown-phase: 10s
# redis 配置
# token配置
token:

View File

@@ -1,73 +0,0 @@
#!/bin/bash
# 石河子后端 自动重启脚本
# VS Code 保存 → Java 扩展编译 → 本脚本检测变更 → 杀旧进程 → 起新进程
# 用法: bash watch.sh
SRC_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SRC_DIR"
APP_CLASS="com.ruoyi.RuoYiApplication"
PORT=9091
echo "================================================"
echo " SHZ Backend 自动重启模式"
echo " 流程: 保存文件 → Java扩展编译 → 检测变更 → 重启服务"
echo " 端口: $PORT"
echo " 按 Ctrl+C 退出"
echo "================================================"
# 获取最新 .java 文件修改时间
get_latest_mtime() {
find . -name "*.java" -path "*/src/*" -type f -printf '%T@\n' 2>/dev/null | sort -rn | head -1 | cut -d'.' -f1
}
# 精准杀后端进程
kill_backend() {
local pid=$(jps -l 2>/dev/null | grep "$APP_CLASS" | awk '{print $1}')
if [ -n "$pid" ]; then
echo "[$(date '+%H:%M:%S')] 🔪 终止旧进程 PID=$pid..."
taskkill //PID "$pid" //F 2>/dev/null
sleep 3
# 确认端口已释放
while netstat -ano 2>/dev/null | grep -q ":$PORT "; do
sleep 2
echo "[$(date '+%H:%M:%S')] ⏳ 等待端口 $PORT 释放..."
done
fi
}
# 启动服务
start_server() {
echo "[$(date '+%H:%M:%S')] 🚀 启动服务..."
cd "$SRC_DIR"
nohup mvn spring-boot:run -pl ruoyi-admin -DskipTests > /tmp/shz-backend.log 2>&1 &
echo "[$(date '+%H:%M:%S')] 等待服务就绪..."
for i in $(seq 1 90); do
sleep 2
curl -s --max-time 2 "http://localhost:$PORT/" > /dev/null 2>&1 && \
echo "[$(date '+%H:%M:%S')] ✅ 服务已就绪: http://localhost:$PORT/" && \
return 0
done
echo "[$(date '+%H:%M:%S')] ⚠️ 启动超时,查看 /tmp/shz-backend.log"
}
# --- 主流程 ---
# 首次启动
kill_backend
start_server
last_ts=$(get_latest_mtime)
while true; do
sleep 3
current_ts=$(get_latest_mtime)
if [ -n "$current_ts" ] && [ -n "$last_ts" ] && [ "$current_ts" -gt "$last_ts" ]; then
echo ""
echo "[$(date '+%H:%M:%S')] 📝 检测到 .java 文件变更,重启服务..."
kill_backend
start_server
last_ts=$(get_latest_mtime)
fi
done