Files
AIGC/demo/scripts/deploy/build-backend-for-baota.sh

54 lines
1.6 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 后端打包脚本 - Linux
echo "========================================"
echo " 后端打包脚本 - Linux"
echo "========================================"
echo ""
# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo "[1/3] 清理旧的构建文件..."
rm -rf target
rm -f backend-dist.tar.gz
rm -rf backend-dist
echo ""
echo "[2/3] 使用Maven打包..."
echo "这可能需要几分钟时间,请耐心等待..."
./mvnw clean package -DskipTests
if [ $? -ne 0 ]; then
echo -e "${RED}错误: Maven打包失败${NC}"
exit 1
fi
echo ""
echo "========================================"
echo " 打包完成!"
echo "========================================"
echo ""
echo -e "${GREEN}JAR包位置: target/demo-0.0.1-SNAPSHOT.jar${NC}"
echo "文件大小:"
ls -lh target/demo-0.0.1-SNAPSHOT.jar | awk '{print $5}'
echo ""
echo "部署到宝塔步骤:"
echo "1. 上传 target/demo-0.0.1-SNAPSHOT.jar 到服务器(如:/www/server/aigc-backend/app.jar"
echo "2. 在服务器创建 application-prod.properties 配置文件"
echo "3. 在宝塔面板使用 Supervisor 或 Java项目管理器启动"
echo ""
echo "启动命令:"
echo " java -jar app.jar --spring.profiles.active=prod"
echo ""
echo "上传命令示例:"
echo " scp target/demo-0.0.1-SNAPSHOT.jar root@your-server:/www/server/aigc-backend/app.jar"
echo ""
echo "注意事项:"
echo "- 确保服务器已安装 Java 21 或更高版本"
echo "- 确保MySQL数据库已创建并配置"
echo "- 需要在服务器上创建 application-prod.properties 配置文件"
echo ""