第一次提交
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
# ========================================
|
||||
# 企业级JWT密钥生成脚本
|
||||
# ========================================
|
||||
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host " 企业级RSA JWT密钥生成工具" -ForegroundColor Cyan
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# 检查Java是否安装
|
||||
try {
|
||||
$javaVersion = java -version 2>&1
|
||||
Write-Host "[✓] Java已安装" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host "[✗] 未检测到Java,请先安装JDK 25+" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "正在生成RSA-2048密钥对..." -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
|
||||
# 编译项目
|
||||
Write-Host "步骤1: 编译项目..." -ForegroundColor Cyan
|
||||
.\mvnw.cmd clean compile -q -DskipTests
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "[✗] 编译失败" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Write-Host "[✓] 编译成功" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
|
||||
# 运行密钥生成器
|
||||
Write-Host "步骤2: 生成密钥对..." -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
java -cp "target/classes" com.caiji.uls.utils.jwt.RsaKeyGenerator
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host " 下一步操作" -ForegroundColor Cyan
|
||||
Write-Host "========================================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host "1. 复制上面生成的公钥和私钥" -ForegroundColor White
|
||||
Write-Host "2. 打开 src/main/resources/application.properties" -ForegroundColor White
|
||||
Write-Host "3. 粘贴到以下配置项:" -ForegroundColor White
|
||||
Write-Host ""
|
||||
Write-Host " jwt.public-key=你的公钥" -ForegroundColor Gray
|
||||
Write-Host " jwt.private-key=你的私钥" -ForegroundColor Gray
|
||||
Write-Host ""
|
||||
Write-Host "⚠️ 重要提示:" -ForegroundColor Yellow
|
||||
Write-Host " - 私钥必须保密,不要提交到Git!" -ForegroundColor Yellow
|
||||
Write-Host " - 生产环境请使用固定密钥对" -ForegroundColor Yellow
|
||||
Write-Host " - 建议将密钥存储在环境变量或密钥管理系统中" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
Reference in New Issue
Block a user