Boost Your Java Projects with Sa-plus: A High‑Performance SpringBoot Code Generator
This guide introduces Sa-plus, a SpringBoot‑based rapid development framework featuring a built‑in code generator, dual UI skins, and integrated JavaWeb utilities, and walks you through setting up the database, importing modules, configuring the application, and automatically generating full‑stack CRUD code and API documentation.
Sa-plus Overview
Sa-plus is a SpringBoot‑based rapid development framework with a built‑in code generator, integrating common JavaWeb features such as file upload, role authorization, global exception handling, Redis console, API logging, configuration, CORS, and unified dialogs.
Project Advantages
Framework integration of common JavaWeb functions.
High‑automation code generation for CRUD, forms, media uploads, tree tables, foreign keys, etc.
Two UI skins: pure HTML (iframe) and Vue‑CLI SPA.
Micro‑service version available.
Technology Stack
Backend: SpringBoot, Mybatis‑Plus, PageHelper, Druid, Redis, Sa‑Token, Lombok, FastJson, Hutool, MySQL 5.7.
Frontend: Sa‑admin, Vue, Element‑UI, Layer, WangEditor, jQuery, Swiper, ECharts.
API documentation: sa‑doc.
Backend Code Structure
sp-server: Java server code. sp-admin: Admin UI. sp-apidoc: API docs. sp-generate: Code generator. sp-devdoc: Sa‑plus documentation. sp-com: Maven multi‑module version. doc: Misc files such as SQL scripts.
Key Packages
├─current
│ ├─config // project configuration
│ ├─global // global behavior (logging, exception)
│ ├─mybatis // MyBatis config
│ ├─satoken // Sa‑Token config
│ │ └─CorsFilter.java
│ │ └─SaFastPrint.java
│ └─...
├─project // modules per table
├─project4sp // built‑in modules
├─utils
│ └─sg
│ ├─AjaxError.java
│ ├─AjaxJson.java
│ └─...
└─SpServerApplication.javaQuick Start
Create a MySQL 5.7 database sp-dev and import doc/sa-plus.sql.
Import sp-server into an IDE, configure application.yml with MySQL and Redis, then run SpServerApplication.
Import sp-admin, open index.html to launch the admin UI.
Import sp-apidoc and edit _sidebar.md to write API documentation.
Import sp-generate, run its SpGenerateApplication main method, set MySQL connection and output paths, then generate backend and frontend code automatically.
Code Generator Configuration Example
@SqlFlySetup
@SpringBootApplication
public class SpGenerateApplication {
public static void main(String[] args) {
SpringApplication.run(SpGenerateApplication.class, args);
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);
GenCfgManager.cfg
.setProjectPath("e:/project/test/sa-plus/")
.setServerProjectName("sp-server")
.setCodePath("src/main/java/")
.setPackagePath("com.pj.project")
.setPackage_utils("com.pj.utils.sg.*")
.setAuthor("macrozheng");
}
}Sample Table Definition
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]';Result
After running the generator, complete CRUD pages, API documentation and front‑end code are created automatically, demonstrating Sa‑plus’s ability to accelerate Java web development.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
