美文网首页
2023-12-25后端工程搭建

2023-12-25后端工程搭建

作者: 大也 | 来源:发表于2023-12-25 09:19 被阅读0次

    1.环境确认


    image.png

    2.工程框架搭建
    spzx-parent: 尚品甄选项目的父工程,进行项目依赖的统一管理,打包方式为pom
    spzx-common: 尚品甄选项目公共模块的管理模块,父工程为spzx-parent
    common-util: 工具类模块,父工程为spzx-common
    common-service:公共服务模块,父工程为spzx-common
    spzx-model: 尚品甄选实体类模块
    spzx-manager: 尚品甄选项目后台管理系统的后端服务

    image.png

    3.设置maven和字符集


    image.png
    image.png

    4.导入依赖
    1).spzx-parent

    <!-- 指定父工程 -->
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>3.0.5</version>
        </parent>
    
        <properties>
            <maven.compiler.source>17</maven.compiler.source>
            <maven.compiler.target>17</maven.compiler.target>
            <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <mysql.verison>8.0.30</mysql.verison>
            <fastjson.version>2.0.21</fastjson.version>
            <lombok.version>1.18.20</lombok.version>
            <mybatis.version>3.0.1</mybatis.version>
        </properties>
    
        <!-- 管理依赖,版本锁定 -->
        <dependencyManagement>
            <dependencies>
                <!-- mybatis和spring boot整合的起步依赖 -->
                <dependency>
                    <groupId>org.mybatis.spring.boot</groupId>
                    <artifactId>mybatis-spring-boot-starter</artifactId>
                    <version>${mybatis.version}</version>
                </dependency>
    
                <!-- mysql驱动 -->
                <dependency>
                    <groupId>mysql</groupId>
                    <artifactId>mysql-connector-java</artifactId>
                    <version>${mysql.version}</version>
                </dependency>
    
                <!--fastjson-->
                <dependency>
                    <groupId>com.alibaba</groupId>
                    <artifactId>fastjson</artifactId>
                    <version>${fastjson.version}</version>
                </dependency>
    
                <!-- lombok依赖 -->
                <dependency>
                    <groupId>org.projectlombok</groupId>
                    <artifactId>lombok</artifactId>
                    <version>${lombok.version}</version>
                </dependency>
            </dependencies>
        </dependencyManagement>
    

    2).spzx-common

    <dependencies>
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.5.2</version>
        </dependency>
    </dependencies>
    

    3 common-util

    <dependencies>
        <!-- fastjson依赖 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
    
        <dependency>
            <groupId>com.atguigu</groupId>
            <artifactId>spzx-model</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    
        <dependency>
            <groupId>io.minio</groupId>
            <artifactId>minio</artifactId>
            <version>8.5.2</version>
        </dependency>
    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <scope>provided </scope>
        </dependency>
    </dependencies>
    

    4 common-service

    <dependencies>
    
        <!-- common-util模块 -->
        <dependency>
            <groupId>com.atguigu</groupId>
            <artifactId>common-util</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    
        <!-- spzx-model模块 -->
        <dependency>
            <groupId>com.atguigu</groupId>
            <artifactId>spzx-model</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    
        <!-- spring boot web开发所需要的起步依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
            <scope>provided</scope>
        </dependency>
    
    </dependencies>
    

    5 spzx-model

    <dependencies>
    
        <!-- lombok的依赖 -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
    
        <dependency>
            <groupId>com.github.xiaoymin</groupId>
            <artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId>
            <version>4.1.0</version>
        </dependency>
    
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>easyexcel</artifactId>
            <version>3.1.0</version>
        </dependency>
    
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
    </dependencies>
    

    6 spzx-manager

    <dependencies>
    
        <!-- spring boot web开发所需要的起步依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    
        <!-- redis的起步依赖 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>
    
        <!-- mybatis的起步依赖 -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
        </dependency>
    
        <!-- mysql驱动 -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
    
        <!-- common-service依赖 -->
        <dependency>
            <groupId>com.atguigu</groupId>
            <artifactId>common-service</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>
    
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.4.3</version>
        </dependency>
    </dependencies>
    
    image.png

    补充知识

    • 一个项目中所涉及到的实体类往往有三种:

    1、封装请求参数的实体类:这种实体类在定义的时候往往会携带到dto【数据传输对象:Data Transfer Object】字样,会定义在dto包中

    2、与数据库对应的实体类:这种实体类往往和数据表名称保证一致,会定义在domain、entity、pojo包中

    3、封装响应结果的实体类:这种实体类在定义的时候往往会携带到vo【视图对象:View Object】字样,会定义在vo包中

    相关文章

      网友评论

          本文标题:2023-12-25后端工程搭建

          本文链接:https://www.haomeiwen.com/subject/zsqhndtx.html