Why Environment Setup Is the Real Pain in Spring Boot Projects (And How to Fix It)

This article walks through the common frustrations of IDE and environment setup for Spring Boot projects, explains version compatibility between Spring Cloud, Spring Boot, and Kafka, demonstrates how Maven and auto‑configuration simplify dependencies, and provides ready‑to‑use code snippets and useful tooling recommendations for backend developers.

Su San Talks Tech
Su San Talks Tech
Su San Talks Tech
Why Environment Setup Is the Real Pain in Spring Boot Projects (And How to Fix It)

1. Project Initialization

Developers often complain that the most painful part of development is the environment, especially downloading and activating IDEs that are frequently paid software, leading to wasted time on cracked versions and license activations.

After setting up the IDE, the article shows how to create a new Spring Boot project, which results in a fresh project containing a main class, configuration files, and a test starter class.

2. Version Management

Compatibility between Spring Cloud and Spring Boot, as well as between Spring Boot and Kafka, is crucial. The article provides reference links:

https://spring.io/projects/spring-cloud
https://spring.io/projects/spring-kafka

Images illustrate the version tables (kept for context).

A real‑world mismatch example is described: the production Kafka server is version 0.11 while the client uses 3.0.4, causing an UnsupportedVersionException because the broker does not support the required message format.

3. Scaffold and Core Classes

The article presents several essential code snippets used in the project.

@RestControllerAdvice
@ResponseBody
@Slf4j
public class GlobalExceptionHandler {
    @ExceptionHandler(value = {MethodArgumentNotValidException.class})
    public ResponseResult<String> handleValidException(MethodArgumentNotValidException ex, HttpServletResponse httpServletResponse) {
        log.error("[GlobalExceptionHandler][handleValidException] 参数校验exception", ex);
        return wrapperBindingResult(ex.getBindingResult(), httpServletResponse);
    }
    private ResponseResult<String> wrapperBindingResult(BindingResult bindingResult, HttpServletResponse httpServletResponse) {
        StringBuilder errorMsg = new StringBuilder();
        for (ObjectError error : bindingResult.getAllErrors()) {
            if (error instanceof FieldError) {
                errorMsg.append(((FieldError) error).getField()).append(": ");
            }
            errorMsg.append(error.getDefaultMessage() == null ? "" : error.getDefaultMessage());
        }
        httpServletResponse.setStatus(HttpStatus.BAD_REQUEST.value());
        return ResponseResult.failed(ResultCode.FAILED.getCode(), null);
    }
}
@Aspect
@Slf4j
@Component
public class WebLogAspect {
    @Pointcut("@within(org.springframework.stereotype.Controller) || @within(org.springframework.web.bind.annotation.RestController)")
    public void cutController() {}
    @Before("cutController()")
    public void doBefore(JoinPoint point) {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
        String url = request.getRequestURL().toString();
        List<Object> list = Lists.newArrayList();
        for (Object object : point.getArgs()) {
            if (object instanceof MultipartFile || object instanceof HttpServletRequest || object instanceof HttpServletResponse || object instanceof BindingResult) {
                continue;
            }
            list.add(object);
        }
        log.info("请求 uri:[{}],params:[{}]", url, StringUtils.join(list, ","));
    }
    @AfterReturning(returning = "response", pointcut = "cutController()")
    public void doAfterReturning(Object response) {
        if (response != null) {
            log.info("请求返回result:[{}]", JSONUtil.toJsonStr(response));
        }
    }
}
@Configuration
public class GlobalCorsConfig {
    @Bean
    public CorsFilter corsFilter() {
        CorsConfiguration config = new CorsConfiguration();
        config.setAllowedOrigins(Lists.newArrayList("*"));
        config.setAllowCredentials(true);
        config.addAllowedHeader("*");
        config.addAllowedMethod("*");
        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
        source.registerCorsConfiguration("/**", config);
        return new CorsFilter(source);
    }
}

@Configuration
@EnableOpenApi
public class SwaggerConfig {
    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                .enable(true)
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.vines.controller"))
                .paths(PathSelectors.any())
                .build();
    }
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("项目描述")
                .description("基础服务项目描述")
                .contact(new Contact("作者", "作者URL", "作者Email"))
                .version("1.0")
                .build();
    }
}
@Data
public class ResponseResult<T> {
    private int code;
    private String message;
    private T data;
    public static <T> ResponseResult<T> success(T data) {
        ResponseResult<T> r = new ResponseResult<>();
        r.setCode(ResultCode.SUCCESS.getCode());
        r.setMessage(ResultCode.SUCCESS.getMessage());
        r.setData(data);
        return r;
    }
    public static <T> ResponseResult<T> success() { /* ... */ }
    public static <T> ResponseResult<T> failed(int code, String message) { /* ... */ }
    public static boolean isSucceed(ResponseResult responseResult) {
        return responseResult.getCode() == ResultCode.SUCCESS.getCode();
    }
}

3.1 Common Tools

Beyond the core libraries, the article recommends several useful tools for development and testing:

Embedded Redis: https://github.com/kstyrc/embedded-redis Embedded DB (MariaDB): https://github.com/mariadb Embedded Kafka (Spring Kafka starter)

Hutool utilities: https://hutool.cn/ MyBatis‑Plus: https://baomidou.com/ MapStruct: https://mapstruct.org/ Redisson:

https://github.com/redisson/redisson

Summary

In real work, configuring the IDE is not the only time‑consuming pain point; mismatched versions between services (e.g., Kafka server vs. client) can cause subtle runtime errors, and managing dependencies manually is error‑prone. Using Maven for dependency management, leveraging Spring Boot’s auto‑configuration, and employing the recommended tools can dramatically improve development efficiency.

Project screenshot
Project screenshot
Version table
Version table
Spring Cloud version
Spring Cloud version
Kafka version
Kafka version
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.

KafkamavenSpring BootIDE setup
Su San Talks Tech
Written by

Su San Talks Tech

Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.

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.