编辑 | blame | 历史 | 原始文档

Cube 快速启动版

版本: 2.6.4

版本特性

在线文档

单体

Java端项目启动

  1. 下载项目
git clone http://125.71.201.11:9004/cube/cube-quick-start.git -b 2.6.4
  1. 项目结构说明
├─cube-quick-start(父POM: 项目依赖、modules组织)
│  ├─system-quick-start (系统管理模块: 系统管理、权限等功能) -- 单体启动项目
│  ├─VERSION.md 与前端版本对应关系
│  ├─{?} 业务模块
  1. 初始化数据库
git clone http://125.71.201.11:9004/cube/cube-db.git -b 2.6.3
  • 建库建表:
  • cube-db/cube-mysql.sql
  • cube-db/cube-dm8.sql
  1. 配置并启动项目
  • system-quick-start/src/main/resources/application-dev.yml 中配置 数据库redis
  • 业务API排除鉴权:**system-quick-start/src/main/resources/application-dev.yml** 中配置 cube.sa-token.exclude-urls
  • system-quick-start/src/main/java/com/tievd/cube/starter/CubeSystemStarter.java 启动项目

前端项目启动

  1. 下载项目
git clone http://125.71.201.11:9004/cube/cube-web.git -b 2.5.1
  1. 执行命令 yarn install
  2. 配置服务接口地址: src/config/index.js -> window._CONFIG['domianURL'] = 'http://127.0.0.1:8080/cube'
  3. 运行yarn serve,访问 http://127.0.0.1:3000
  4. 默认账号 admin 123456

如何升级魔方

  1. 在VERSION.md对应版本号
  2. Java通过Maven私服分发,修改顶级pom中 cube-dependencies 的版本号
  3. 前端通过NPM私服分发,修改package.json中的@tievd前缀下的包的版本号,web代码则是通过切换分支覆盖文件

如何快速开发

  1. 在cube-quick-start目录下新建业务的 module
  2. 在新建的业务module中引入魔方框架提供的API库
<dependencies>
    <!-- 提供基础API -->
    <dependency>
        <groupId>com.tievd.cube.base</groupId>
        <artifactId>system-local-api</artifactId>
    </dependency>
    <!-- 提供完整API(包含基础API) -->
    <dependency>
        <groupId>com.tievd.cube</groupId>
        <artifactId>cube-system-service</artifactId>
    </dependency>
</dependencies>
  1. 将业务module作为依赖引入到 system-quick-start
  2. 阅读代码生成器文档
  3. 设计Java实体类(数据库/UI组件绑定/字段分组) -> 在线开发 -> 代码生成 -> 拷贝到项目中
  4. 将vue代码拷贝到前端项目 src/views/modules 目录中
  5. 将新增代码重新编译运行,在系统管理 -> 菜单管理 中添加业务菜单并绑定到前端组件路径
  6. 通过系统管理 ->角色管理 -> 授权 给用户菜单权限

开发技巧

  1. 如何在代码中获取当前登录用户
// 当前登陆用户的信息
LoginUser sysUser = SystemContextUtil.currentLoginUser();
  1. 如何开启字典渲染

为了节省不必要的消耗,现在字典翻译需要在Controller的函数或类上注解才能渲染。

// 单个函数渲染
@DictMethod
// 整个类的函数都需要渲染
@DictApi
  1. API文档生成

现在默认使用SpringDoc作为默认的文档规范,标准为OpenAPI 3,底层使用到了swagger。

cube-system可选组件

cube-system-modules

微服务

微服务可选组件

魔方基础服务切换到微服务

  1. system-quick-start 添加依赖
<!-- 引入starter-cloud依赖 -->
<dependency>
    <groupId>com.tievd.cube.starter</groupId>
    <artifactId>starter-cloud</artifactId>
    <!--system模块需要排除cube-cloud-api-->
    <exclusions>
        <exclusion>
            <groupId>com.tievd.cube.base</groupId>
            <artifactId>system-cloud-api</artifactId>
        </exclusion>
    </exclusions>
</dependency>
  1. 修改配置Nacos注册中心和配置中心
  • 删除system-quick-start/src/main/resources下的application-{dev/prod}.yml配置文件,只保留application.yml,并加入以下配置
server:
  port: 8090
spring:
  application:
    name: cube-system
cube:
  version: @cube.version@
  • system-quick-start/src/main/resources/bootstrap.yml 取消注释,修改Nacos配置
  1. 启动其他模块(网关,监控)

业务模块切换到微服务模式

和魔方基础服务一样,只需要新增一个启动类即可

  1. 添加依赖
<dependency>
    <groupId>com.tievd.cube.starter</groupId>
    <artifactId>starter-cloud</artifactId>
</dependency>
  1. 新增一个启动类 DemoApplication.java 并注解 @CubeCloudApp

@CubeCloudApp public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }
  1. 魔方提供 system-cloud-api 来调用一些底层API
  2. 添加相同配置文件:配置Nacos注册中心和配置中心等
  3. Demo代码示例
编辑 | blame | 历史 | 原始文档
MIT License

Copyright (c) 2019-2022 Tievd

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.