Cloud Native 13 min read

Upgrade Mall‑Swarm to Spring Boot 3 & Spring Cloud 2023: A Complete Guide

This article walks through upgrading the Mall‑Swarm microservice e‑commerce project to Spring Boot 3, Spring Cloud 2023, JDK 17, and related dependencies, covering architecture, version changes, permission solution migration, documentation updates, Elasticsearch usage, and deployment on Windows and Linux.

macrozheng
macrozheng
macrozheng
Upgrade Mall‑Swarm to Spring Boot 3 & Spring Cloud 2023: A Complete Guide

Mall‑Swarm Project Overview

mall‑swarm is a microservice e‑commerce system with over 11k stars, built on Spring Cloud Alibaba, Spring Boot 3.2, JDK 17 and Kubernetes, and includes a Vue‑based admin UI.

GitHub: https://github.com/macrozheng/mall-swarm

Gitee: https://gitee.com/macrozheng/mall-swarm

Video tutorials: https://cloud.macrozheng.com/video/

System Architecture

The project uses a mainstream microservice stack covering most common technologies.

Version Upgrades

All dependencies have been upgraded to the latest mainstream versions, such as Spring Cloud 2023.0.1, Spring Cloud Alibaba 2023.0.1, Spring Boot 3.2.2, Sa‑Token, Nacos 2.3.0, MyBatis 3.5.14, Knife4j 4.5.0, Druid 1.2.21, Hutool 5.8.16, etc.

Upgrade Usage

Key changes include replacing Spring Security Oauth2 with Sa‑Token for permission control, migrating Knife4j documentation from SpringFox to SpringDoc, and using the new Spring Data Elasticsearch API.

Permission Solution Upgrade

AuthorizationManager is replaced by SaReactorFilter in the gateway. Example configuration:

<code>@Configuration
public class SaTokenConfig {
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @Bean
    public SaReactorFilter getSaReactorFilter(IgnoreUrlsConfig ignoreUrlsConfig) {
        return new SaReactorFilter()
                .addInclude("/**")
                .setExcludeList(ignoreUrlsConfig.getUrls())
                .setAuth(obj -> {
                    SaRouter.match(SaHttpMethod.OPTIONS).stop();
                    SaRouter.match("/mall-portal/**", r -> StpMemberUtil.checkLogin()).stop();
                    SaRouter.match("/mall-admin/**", r -> StpUtil.checkLogin());
                    Map<Object, Object> pathResourceMap = redisTemplate.opsForHash().entries(AuthConstant.PATH_RESOURCE_MAP);
                    List<String> needPermissionList = new ArrayList<>();
                    String requestPath = SaHolder.getRequest().getRequestPath();
                    PathMatcher pathMatcher = new AntPathMatcher();
                    for (Map.Entry<Object, Object> entry : pathResourceMap.entrySet()) {
                        String pattern = (String) entry.getKey();
                        if (pathMatcher.match(pattern, requestPath)) {
                            needPermissionList.add((String) entry.getValue());
                        }
                    }
                    if (CollUtil.isNotEmpty(needPermissionList)) {
                        SaRouter.match(requestPath, r -> StpUtil.checkPermissionOr(Convert.toStrArray(needPermissionList)));
                    }
                })
                .setError(this::handleException);
    }
}
</code>

Added Sa‑Token with Redis for distributed session handling in admin and portal modules.

Auth module simplified by remote login call.

Knife4j Documentation Upgrade

Switched from SpringFox to SpringDoc; the API docs are still accessed at http://localhost:8201/doc.html. Annotation mappings are provided.

Spring Data Elasticsearch New Usage

ElasticsearchTemplate replaces the removed ElasticsearchRestTemplate for complex queries. Example service implementation:

<code>@Service
public class EsProductServiceImpl implements EsProductService {
    @Autowired
    private ElasticsearchTemplate elasticsearchTemplate;

    @Override
    public Page<EsProduct> search(String keyword, Long brandId, Long productCategoryId,
                                 Integer pageNum, Integer pageSize, Integer sort) {
        // build query, filter, sort, execute and return results
    }
}
</code>

Compatible with ES 7.17.3 and ES 8.x.

Deployment

Windows

Run with JDK 17 as required by Spring Boot 3.

Linux/Docker

Use openjdk:17 base image and configure the docker‑maven‑plugin in pom.xml. Pull the image with

docker pull openjdk:17

.

Summary

All framework versions upgraded to the latest.

Permission solution migrated from Spring Security Oauth2 to Sa‑Token.

API documentation migrated from SpringFox to SpringDoc.

Product search now uses Spring Data Elasticsearch.

Project requires JDK 17 for building and deployment.

DockerMicroserviceskubernetesSpring CloudSa-TokenSpring Boot 3
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

login 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.