How to Quickly Bootstrap a Full‑Stack Project with sa‑plus Code Generator

This guide introduces the sa‑plus framework—a SpringBoot‑based rapid‑development scaffold with an integrated code generator that can automatically produce backend, frontend, and API documentation code from database tables, and walks through its architecture, technology stack, module structure, quick start steps, and code‑generation features.

macrozheng
macrozheng
macrozheng
How to Quickly Bootstrap a Full‑Stack Project with sa‑plus Code Generator

sa-plus Overview

sa-plus is a rapid‑development framework based on SpringBoot that includes a built‑in code generator capable of generating backend, frontend and API documentation code with a single click.

Project Architecture

The project consists of several modules:

sp-server – SpringBoot backend code.

sp-admin – Vue admin frontend code.

sp-apidoc – Docsify API documentation code.

sp-generate – Code generator that produces backend, frontend and API docs.

sp-devdoc – Local documentation.

doc – Miscellaneous files such as SQL scripts.

Technology Stack

Backend: MySQL 5.7, SpringBoot, Mybatis‑Plus, Druid, PageHelper, Redis, Sa‑Token, Lombok, Hutool, FastJson.

Frontend: Vue, Element‑UI, WangEditor, jQuery, Layer, Swiper, ECharts.

Quick Start

sp-server

Create a MySQL database sp-dev and import sa-plus.sql from the doc directory.

Import the sp-server module into IDEA.

Modify application-dev.yml to set your MySQL and Redis connection parameters.

Run the main class SpServerApplication. The backend starts on port 8099.

spring:
  # datasource configuration
  datasource:
    type: com.alibaba.druid.pool.DruidDataSource
    url: jdbc:mysql://127.0.0.1:3306/sp-dev?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC
    username: root
    password: root

  # redis configuration
  redis:
    database: 1
    host: 127.0.0.1
    port: 6379
    timeout: 5000ms

sp-admin

Import the sp-admin module into IDEA.

Open index.html and run it in a browser.

Log in with the default credentials to access the sa‑plus home page.

Explore features such as the Redis console, API request logs, role management, menu management and user management.

sp-apidoc

Import the sp-apidoc module and open index.html to view the API documentation (initially empty).

Code Generator

Import the sp-generate module.

Import test data from doc/test-data.sql into MySQL.

Configure MySQL connection and generation paths in SpGenerateApplication.

Run the main method of SpGenerateApplication to generate code.

@SqlFlySetup
@SpringBootApplication
public class SpGenerateApplication {
    // Directly run the code generator
    public static void main(String[] args) {
        SpringApplication.run(SpGenerateApplication.class, args);

        // Set connection information
        FlyConfig config = new FlyConfig();
        config.setDriverClassName("com.mysql.jdbc.Driver");
        config.setUrl("jdbc:mysql://127.0.0.1:3306/sp-dev?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC");
        config.setUsername("root");
        config.setPassword("root");
        config.setPrintSql(true);
        FlyObjects.setConfig(config);

        // Global settings
        GenCfgManager.cfg
            .setProjectPath("D:/developer/demo/sa-plus/")
            .setServerProjectName("sp-server")
            .setCodePath("src/main/java/")
            .setPackagePath("com.pj.project")
            .setPackage_utils("com.pj.utils.sg.*")
            .setAuthor("macrozheng");
    }
}

After execution, backend code is generated under sp-server/src/main/java/com/pj/project, frontend code under sp-admin/sa-html (with menu definitions added to menu-list.js), and API documentation under sp-apidoc/project.

SQL Example for Code Generation

CREATE TABLE `ser_goods` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '记录id [num no-add]',
  `name` varchar(200) DEFAULT NULL COMMENT '商品名称 [text j=like]',
  `avatar` varchar(512) DEFAULT NULL COMMENT '商品头像 [img]',
  `image_list` varchar(2048) DEFAULT NULL COMMENT '轮播图片 [img-list]',
  `content` text COMMENT '图文介绍 [f]',
  `money` int(11) DEFAULT '0' COMMENT '商品价格 [num]',
  `type_id` bigint(20) DEFAULT NULL COMMENT '所属分类 [num]',
  `stock_count` int(11) DEFAULT '0' COMMENT '剩余库存 [num]',
  `status` int(11) DEFAULT '1' COMMENT '商品状态 (1=上架,2=下架) [j]',
  `create_time` datetime DEFAULT NULL COMMENT '创建日期 [date-create]',
  `update_time` datetime DEFAULT NULL COMMENT '更新日期 [date-update]',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1005 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='商品表
[table icon=el-icon-apple]
[fk-s js=(type_id=sys_type.id), show=name.所属分类, drop]';

The generated API documentation provides detailed CRUD interfaces for the product table, including an integrated testing console.

Conclusion

sa‑plus offers a convenient scaffold with built‑in functionalities and a powerful code generator that can dramatically speed up development, though complex scenarios may still require manual coding, and its permission model could be improved.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

VuemysqlSpringBootfull-stack
macrozheng
Written by

macrozheng

Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.