Home  >  Article  >  Java  >  What are the commonly used directories for springBoot projects?

What are the commonly used directories for springBoot projects?

王林
王林forward
2023-06-27 13:42:231266browse

Common directories for springBoot projects

What are the commonly used directories for springBoot projects?

##The directory structure and name specifications of the springBoot project

Introduces the directory structure and naming specifications when developing based on SpringBoot. Through the introduction Can we solve it for you, how to plan the directory structure in actual projects? How to name directories more standardizedly? What do each directory mean? Wait three questions.

Directory description

servicex                 // 项目名
    |- admin-ui          // 管理服务前端代码(一般将UI和SERVICE放到一个工程中,便于管理)
    |- servicex-auth     // 模块1
    |- servicex-common   // 模块2
    |- servicex-gateway  // 模块3
    |- servicex-system   // 模块4
        |- src
            |- main                  // 业务逻辑
                |- assembly          // 基于maven assembly插件的服务化打包方案
                    |- bin           // 模块脚本(启动、停止、重启)
                    |- sbin          // 管理员角色使用的脚本(环境检查、系统检测等等)
                    |- assembly.xml  // 配置文件
                |- java              // 源码
                    |- com
                        |- hadoopx
                            |- servicex
                                |- system
                                    |- annotation     // 注解
                                    |- aspect         // 面向切面编程
                                    |- config         // 配置文件POJO
                                    |- filter         // 过滤器
                                    |- constant       // 存放常量
                                    |- utils          // 工具
                                    |- exception      // 异常
                                    |- controller     // 控制层(将请求通过URL匹配,分配到不同的接收器/方法进行处理,然后返回结果)
                                    |- service        // 服务层接口
                                        |- impl       // 服务层实现
                                    |- mapper/repository // 数据访问层,与数据库交互为service提供接口
                                    |- entity/domain     // 实体对象
                                        |- dto // 持久层需要的实体对象(用于服务层与持久层之间的数据传输对象)
                                        |- vo // 视图层需要的实体对象(用于服务层与视图层之间的数据传输对象)
                                    |- *Application.java  // 入口启动类
                |- resources         // 资源
                    |- static        // 静态资源(html、css、js、图片等)
                    |- templates     // 视图模板(jsp、thymeleaf等)
                    |- mapper        // 存放数据访问层对应的XML配置
                        |- *Mapper.xml
                        |- ...
                    |- application.yml        // 公共配置
                    |- application-dev.yml    // 开发环境配置
                    |- application-prod.yml   // 生产环境配置
                    |- banner.txt    
                    |- logback.xml            // 日志配置
            |- test                  // 测试源码
               |- java               
                    |- com
                        |- hadoopx
                            |- servicex
                                |- system
                                    |- 根据具体情况按源码目录结构存放编写的测试用例
        |- target     // 编译打包输出目录(自动生成,不需要创建)
        |- pom.xml    // 该模块的POM文件
    |- sql            // 项目需要的SQL脚本
    |- doc            // 精简版的开发、运维手册
    |- .gitignore     // 哪些文件不用传到版本管控工具中
    |- pom.xml        // 工程总POM文件
    |- README.md      // 注意事项
External Libraries    // 相关JAR包依赖

Notes

(1). mapper/repository, data access layer, interacts with the database to provide an interface for the service (add, delete, and modify a certain table Check, a ’*Mapper.java’ and a ’*Mapper.xml’ correspond to a table (if there is a related query); Mybatis uses mapper, and JPA uses repository)

( 2). Entity/domain, data entity class (Mybatis uses entity, JPA uses domain)

(3). The meaning of POJO, VO, DTO, DO, PO, BO:

  • POJO: It is a simple, ordinary JAVA object, which contains business logic processing or persistence logic, etc. But it is not JavaBean, EntityBean, etc., does not have any special role, does not inherit or implement any other JAVA framework classes or interfaces. Can contain objects similar to JavaBean properties and setter and getter methods for property access.

  • VO(View Object): View object, used for display layer display, representing the data that needs to be displayed in the display layer. Its function is to encapsulate all the data required by a specific page/component.

  • DTO(Data Transfer Object): Data transfer object, used for data transfer objects between the service layer and the persistence layer, representing the service layer that needs to receive/return The data.

  • DO(Domain Object): Domain object is a tangible or intangible entity object abstracted from the real world.

  • PO (Persistent Object): Persistence object, which forms a one-to-one mapping relationship with the data structure of the persistence layer (usually a relational database). Each field (or several) in the data table corresponds to one (or several) attributes of PO.

  • BO(Business Object): Business object is used to encapsulate business logic into an object, which can include one or more other objects.

  • ##POJO

    After persistence-> PO; During POJO transmission-> DTO; POJO is used as the presentation layer-> VO

The above is the detailed content of What are the commonly used directories for springBoot projects?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete