Simplify SpringBoot Development with Mall‑Tiny: A Full‑Feature Backend Scaffold
mall‑tiny is an open‑source SpringBoot + MyBatis‑Plus scaffold that streamlines backend development by providing a lightweight project skeleton with integrated permission management, Docker support, Swagger documentation, and code generation tools, enabling rapid setup, customization, and deployment of secure REST APIs.
Introduction
mall‑tiny is a rapid development scaffold based on SpringBoot and MyBatis‑Plus, offering complete permission management and ready integration with the Vue front‑end.
Project Demo
mall‑tiny can be seamlessly connected to the mall‑admin‑web front‑end to become a permission management system. Front‑end project address: https://github.com/macrozheng/mall-admin-web
Technical Stack
SpringBoot 2.3.0 – container and MVC framework
SpringSecurity 5.3.2 – authentication and authorization
MyBatis 3.5.4 – ORM framework
MyBatis‑Plus 3.3.2 – enhancement tool
MyBatis‑Plus Generator 3.3.2 – data layer code generator
Swagger‑UI 2.9.2 – API documentation
Redis 5.0 – distributed cache
Docker 18.09.0 – application container engine
Druid 1.1.10 – database connection pool
JWT 0.9.0 – token authentication
Lombok 1.18.12 – boilerplate reduction
Database Structure
The scaffold retains only nine tables related to permission management for easy customization. The SQL file is available at the GitHub repository.
Usage Process
Environment Setup
Only MySQL and Redis are required. Follow the deployment guide for Windows to install services, then import the mall_tiny.sql script.
Development Specification
Project Package Structure
src
├── common // common code
│ ├── api
│ ├── config
│ ├── domain
│ ├── exception
│ └── service
├── config // SpringBoot Java config
├── domain // shared objects
├── generator // MyBatis‑Plus code generator
├── modules
│ └── ums // permission module
│ ├── controller
│ ├── dto
│ ├── mapper
│ ├── model
│ └── service
└── security // SpringSecurity related code
├── annotation
├── aspect
├── component
├── config
└── utilResource Files
resources
├── mapper // MyBatis mapper XML files
├── application.yml // common SpringBoot config
├── application-dev.yml // dev environment config
├── application-prod.yml // production config
└── generator.properties // MyBatis‑Plus generator configAPI Definition Rules
Create record: POST /{controller}/create
Update record: POST /{controller}/update/{id}
Delete record: POST /{controller}/delete/{id}
Paginated query: GET /{controller}/list
Get detail: GET /{controller}/{id}
See Swagger‑UI for detailed parameters and responses.
Project Run
Run the main method of MallTinyApplication (the main function) to start the application.
Business Code Development
Create Business Tables
When creating tables in the pms module, ensure each column has a comment so that entity classes and API docs generate field descriptions automatically.
Use Code Generator
Execute the MyBatisPlusGenerator class’s main method to generate controller, service, mapper, model, and mapper.xml code without manual effort.
Single‑table mode: input module name (e.g., pms) and table name (e.g., pms_brand).
Module‑wide mode: input module name (e.g., pms) and pattern (e.g., pms_*) to generate all tables.
Write Business Code
Single‑Table Query
MyBatis‑Plus provides powerful extensions, allowing most single‑table queries without writing SQL, using methods from ServiceImpl and BaseMapper .
/** Backend menu management Service implementation */
@Service
public class UmsMenuServiceImpl extends ServiceImpl<UmsMenuMapper, UmsMenu> implements UmsMenuService {
@Override
public boolean create(UmsMenu umsMenu) {
umsMenu.setCreateTime(new Date());
updateLevel(umsMenu);
return save(umsMenu);
}
// other methods omitted for brevity
}Pagination Query
MyBatis‑Plus natively supports pagination; simply create a Page object and call the page method.
@Override
public Page<UmsMenu> list(Long parentId, Integer pageSize, Integer pageNum) {
Page<UmsMenu> page = new Page<>(pageNum, pageSize);
QueryWrapper<UmsMenu> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(UmsMenu::getParentId, parentId).orderByDesc(UmsMenu::getSort);
return page(page, wrapper);
}Multi‑Table Query
For multi‑table queries, define methods in the Mapper interface and write the corresponding SQL in the mapper XML.
public interface UmsMenuMapper extends BaseMapper<UmsMenu> {
/** Get menu list by admin ID */
List<UmsMenu> getMenuList(@Param("adminId") Long adminId);
} <select id="getMenuList" resultType="com.macro.mall.tiny.modules.ums.model.UmsMenu">
SELECT m.id, m.parent_id, m.create_time, m.title, m.level, m.sort,
m.name, m.icon, m.hidden
FROM ums_admin_role_relation arr
LEFT JOIN ums_role r ON arr.role_id = r.id
LEFT JOIN ums_role_menu_relation rmr ON r.id = rmr.role_id
LEFT JOIN ums_menu m ON rmr.menu_id = m.id
WHERE arr.admin_id = #{adminId} AND m.id IS NOT NULL
GROUP BY m.id
</select>Project Deployment
mall‑tiny includes Docker support; you can build a Docker image using the Maven plugin (see the guide).
Other Notes
SpringSecurity
SpringSecurity is used for authentication and authorization; some APIs require a token obtained via the login endpoint.
Visit Swagger‑UI at http://localhost:8080/swagger-ui.html
Call the login API to obtain a token.
Enter the token via the Authorize button to access protected APIs.
Request Parameter Validation
The project integrates Jakarta Bean Validation; add annotations from javax.validation.constraints to DTO fields and use @Validated on controller methods.
@Data
public class UmsAdminLoginParam {
@NotEmpty
private String username;
@NotEmpty
private String password;
} @PostMapping("/login")
public CommonResult login(@Validated @RequestBody UmsAdminLoginParam param) {
// login logic...
}Project Repository
GitHub: https://github.com/macrozheng/mall-tiny
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.
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.
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.
