Section 3: recommended directory structure of web projects in SpringBoot

The SpringBoot 365 plan began to be updated. The plan knocked 365 SpringBoot cases to review and summarize to form a knowledge system. At present, 32 sections have been output. All source code is hosted on GitHub and Gitee.

Here is the directory structure I created

.
├── ./pom.xml
└── ./src
    ├── ./src/main
    │   ├── ./src/main/java
    │   │   └── ./src/main/java/com
    │   │       └── ./src/main/java/com/rumenz
    │   │           ├── ./src/main/java/com/rumenz/Lession3Application.java
    │   │           ├── ./src/main/java/com/rumenz/config
    │   │           ├── ./src/main/java/com/rumenz/controller
    │   │           ├── ./src/main/java/com/rumenz/domain
    │   │           ├── ./src/main/java/com/rumenz/dto
    │   │           ├── ./src/main/java/com/rumenz/entity
    │   │           ├── ./src/main/java/com/rumenz/mapper
    │   │           ├── ./src/main/java/com/rumenz/repository
    │   │           ├── ./src/main/java/com/rumenz/service
    │   │           │   ├── ./src/main/java/com/rumenz/service/1.txt
    │   │           │   └── ./src/main/java/com/rumenz/service/impl
    │   │           ├── ./src/main/java/com/rumenz/utils
    │   │           └── ./src/main/java/com/rumenz/vo
    │   └── ./src/main/resources
    │       ├── ./src/main/resources/application.properties
    │       ├── ./src/main/resources/mapper
    │       ├── ./src/main/resources/static
    │       └── ./src/main/resources/templates
    └── ./src/test
        └── ./src/test/java
            └── ./src/test/java/com
                └── ./src/test/java/com/rumenz
                    └── ./src/test/java/com/rumenz/Lession3ApplicationTests.java

Project structure

Startup class

Lession3Application.java is usually placed on COM Rumenz lower

Front end controller

The front controller, also known as the controller layer, is placed in the/ src/main/java/com/rumenz/controller path, that is, com rumenz. Controller package.

service interface layer

Also known as the service layer, it is placed in the/ src/main/java/com/rumenz/service path, that is, com rumenz. Under the service package.

Service interface implementation layer impl

The specific implementation classes of the service interface layer are placed in/ src/main/java/com/rumenz/service/impl path, that is, com rumenz. service. Impl package.

Data access layer repository or mapper

Interface to access data library

  • jpa project: put in/ src/main/java/com/rumenz/repository. That is, com rumenz. Under the repository package.
  • mybatis project: put in/ src/main/java/com/rumenz/mapper. That is, com rumenz. Mapper package.

Tool class library utils

Put some common gadgets and methods. Put it on/ src/main/java/com/rumenz/utils. That is, com rumenz. Utils package.

Configuration class config

All configuration classes for the project. Put it on/ src/main/java/com/rumenz/config. That is, com rumenz. Config package.

Data transfer object DTO

DTO(Data Transfer Object) represents a data transfer object. DTO is usually used to transfer objects between the front-end control layer controller and the service layer service. DTO is generally not returned directly to the front-end, but returned by the service layer. The fields displayed in the front-end interface will be newly encapsulated into a VO(View Object)

Front view object VO

VO(View Object) is used to encapsulate the display fields of the front-end interface. Put it on/ src/main/java/com/rumenz/vo. That is, com rumenz. Under the VO bag.

Directory structure of static resources

configuration file

./src/main/resources/application.properties

Static resource directory

. / src/main/resources/static is used to store static resources such as CSS, JS and image.

templates directory

. / src/main/resources/templates is used to store html templates.

mybatis mapping file

. / src/main/resources/mapper is used to store the sql file of xml.

Complete project structure

Source code address of this summary:

introduce

  • Follow the [entry station] and reply to [1001] to get the quick reference manual of common linux commands
  • Follow the [entry station] reply [1003] to get the LeetCode problem solution [implemented in java language]
  • Follow the [entry station] and reply to [1004] to get the basic core summary of Java
  • Follow [entry site] and reply to [1009] to obtain Alibaba Java development manual

Keywords: Web Development Spring Boot

Added by dhe on Thu, 20 Jan 2022 23:21:23 +0200