Banner

NiceFish

2026-11-20

第一部分:部署前端 Angular 版 NiceFish

步骤 1:拉取源码

git clone https://gitee.com/mumu-osc/NiceFish.git
cd NiceFish

步骤 2:安装 Angular CLI(先卸载旧版本)

# 卸载旧版cli
npm uninstall -g @angular/cli angular-cli
# 安装指定版本cli
npm install -g @angular/cli@8.3.29
# 切换淘宝源,解决依赖下载失败
npm config set registry https://registry.npmmirror.com

步骤 3:安装项目依赖

npm install
坑点:node-sass 版本绑定 Node12,Node 版本不对直接报错;如果卡死,删除 node_modules、package-lock.json 重装

步骤 4:本地开发启动

ng serve --open

启动成功访问:http://localhost:4200

步骤 5:修改接口地址对接后端

打开 src/environments/environment.ts

export const environment = {
  production: false,
  apiUrl: 'http://127.0.0.1:8080/api'
};

改为你的后端服务地址。

步骤 6:打包生产包

ng build --prod

打包产物输出在 dist/NiceFish 目录,这个文件夹就是静态资源。

步骤 7:Nginx 部署前端静态文件

上传 dist/NiceFish 内全部文件到服务器 /data/www/nicefish
nginx 配置:

server {
    listen 80;
    server_name shturl.cc/mSmVqU;
    root /data/www/nicefish;
    index index.html;
    location / {
        try_files $uri $uri/ /index.html;
    }
    # 反向代理后端接口
    location /api {
        proxy_pass http://127.0.0.1:8080/api;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

校验重载:

nginx -t
nginx -s reload

第二部分:部署 SpringBoot 后端 nicefish-spring-boot

步骤 1:拉取后端源码

git clone https://gitee.com/mumu-osc/nicefish-spring-boot.git
cd nicefish-spring-boot

步骤 2:初始化数据库

找到 docs/nicefish_springboot.sql,在 MySQL 中执行导入,自动创建表、初始化管理员账号。

步骤 3:修改配置文件

打开 src/main/resources/application.yml

spring:
  datasource:
    url: jdbc:mysql://127.0.0.1:3306/nicefish?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai
    username: root
    password: 你的数据库密码
  redis:
    host: 127.0.0.1
    port: 6379
    password:

修改数据库、Redis 连接信息。

项目依赖 lombok,IDEA 需要安装 lombok 插件

步骤 4:Maven 打包

mvn clean package -DskipTests

打包完成后 target 目录生成 jar 包。

步骤 5:运行后端

java -jar nicefish-cms-xxx.jar

默认端口:8080

SpringCloud 版本补充说明

nicefish-spring-cloud 是微服务版本,需要启动注册中心、网关、认证服务,OAuth2+JWT 做 SSO,适合学习微服务授权,部署复杂度高,不适合新手。

三、目录简要说明(Angular 前端)

NiceFish
├── src
│   ├── app
│   │   ├── core        # 全局拦截器、权限、登录逻辑
│   │   ├── shared      # 公共组件、指令、管道
│   │   ├── pages       # 业务页面:文章、用户、角色、评论
│   │   ├── layout      # 后台布局、侧边栏、顶部导航
│   │   └── app-routing # 路由配置,动态路由加载
│   ├── assets          # 图片、静态资源
│   ├── environments    # 环境变量(开发/生产接口地址)
│   └── styles          # 全局样式
├── angular.json        # Angular项目配置
└── package.json


22