我复现 learning-demo 项目的过程

星期四, 4月 9, 2026 | 1分钟阅读 | 更新于 星期四, 4月 9, 2026

@

我使用 AI 生成了一个 learnging-demo 项目,springboot 后端 + vue3 前端,后端和数据库使用了 redis,mybatis,卡夫卡,mysql,常用的都用上了。

我自己按照 AI 给出的步骤手动一步步复现一个完整的项目出来。

开始

从一个 springboot 的 starter 开始。

Spring Boot Starter

打开项目之后是这样。

打开项目

修改 pom.xml,添加需要的依赖。

添加 mybatis-plus,卡夫卡,redis 依赖。

<dependencies>
    <!-- jdbc -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jdbc</artifactId>
    </dependency>

    <!-- web -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <!-- mysql -->
    <dependency>
        <groupId>com.mysql</groupId>
        <artifactId>mysql-connector-j</artifactId>
        <scope>runtime</scope>
    </dependency>

    <!-- lombok -->
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>

    <!-- test -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>

    <!-- mybatis-plus -->
    <dependency>
        <groupId>com.baomidou</groupId>
        <artifactId>mybatis-plus-spring-boot3-starter</artifactId>
        <version>3.5.6</version>
    </dependency>

    <!-- redis -->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>

    <!-- kafka -->
    <dependency>
        <groupId>org.springframework.kafka</groupId>
        <artifactId>spring-kafka</artifactId>
    </dependency>
</dependencies>

删除 application.properties,创建 application.yml 文件。在其中添加好端口,数据库的配置等。

application.yml 配置

数据库

启动mysql,运行在默认端口3306,用户名root,密码root

创建一个database learning_demo,创建一个数据表t_user

插入两条数据做测试。

数据库创建

遇到的问题

  1. 修改了mvn.xml添加依赖之后,报错:Could not find artifact com.baomidou:mybatis-plus-spring-boot3-starter🫙unknown in alimaven (http://maven.aliyun.com/nexus/content/repositories/central/ )

是因为没有指定 mybatis 的版本号。指定了版本号之后就好了。因为 mybatis-plus 不是 springboot 官方自带的组件。

© 2026 My Blog

🌱 Powered by Hugo with theme Dream.