How to Build a Clean SpringBoot Scaffold Quickly
The article walks through creating a SpringBoot project from scratch, covering IDE setup pain points, project initialization, version compatibility between SpringBoot, Spring Cloud and Kafka, Maven dependency management, core scaffold classes such as global exception handling, logging aspect, CORS and Swagger configuration, and recommends useful tools like embedded Redis, MariaDB, Hutool, MyBatis‑Plus, MapStruct and Redisson.
1. Project Initialization
The author starts by highlighting that developers often dread environment setup, especially downloading and activating IDEs, and notes that the community version of JetBrains IDEs is free while paid versions require licensing.
Using the IDE, a new SpringBoot project is created, resulting in a fresh project structure with a main class, configuration file, and a test startup class.
2. Version Management
After project creation, the author warns about version mismatches. A table (image) shows the compatibility between Spring Cloud and SpringBoot versions, and another table (image) shows the compatibility between SpringBoot and Kafka client versions.
An example is given where the production Kafka broker is version 0.11, but the client uses 3.0.4 and SpringBoot 2.7.x. Although SpringBoot and the Kafka client are compatible, the client and broker are not, leading to the following error:
?,?:Exception thrown when sending a message with key='null' and payload='byte[205]' to topic notify
org.apache.kafka.common.errors.UnsupportedVersionException: Attempting to use idempotence with a broker which does not support the required message format (v2). The broker must be version *0.11* or later.The root cause is the mismatch between production and test environment versions.
The author then introduces Maven as the tool that resolves dependency version conflicts, noting that SpringBoot’s auto‑configuration reduces manual dependency handling and improves development efficiency by about 50%.
3. Scaffold Core Classes
The article lists the core classes included in the scaffold:
GlobalExceptionHandler – Handles validation exceptions and returns a unified ResponseResult object.
WebLogAspect – An AOP aspect that logs request URLs, parameters, and response results.
GlobalCorsConfig – Configures a permissive CORS filter allowing all origins, methods, and headers.
SwaggerConfig – Sets up Swagger/OpenAPI documentation for the com.vines.controller package.
ResponseResult – A generic wrapper for API responses with static factory methods for success and failure.
3.1 Common Tools
Beyond the core scaffold, the author recommends several utilities frequently used in projects:
Embedded Redis: https://github.com/kstyrc/embedded-redis Embedded MariaDB: https://github.com/mariadb Spring Kafka starter for an in‑memory Kafka test dependency.
Hutool: https://hutool.cn/ MyBatis‑Plus: https://baomidou.com/ MapStruct: https://mapstruct.org/ Redisson:
https://github.com/redisson/redissonConclusion
The author reflects that while IDE configuration is often seen as the biggest pain point, version incompatibility between environments can be even more time‑consuming, especially when it leads to runtime errors like the Kafka version mismatch described earlier.
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 Architect Handbook
Focused on Java interview questions and practical article sharing, covering algorithms, databases, Spring Boot, microservices, high concurrency, JVM, Docker containers, and ELK-related knowledge. Looking forward to progressing together with you.
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.
