The development environment of "Kingqiong Takeaway"
Dark Horse Programmer's latest Java project actual combat "Sky Takeaway", the most suitable SpringBoot+SSM enterprise-level Java project actual combat for novices.
Front-end environment construction
The front-end project runs based on nginx, because the "Kangqiong Takeaway" project focuses on the back-end development, so the dark horse programmers directly provided us with the front-end code part, we only need to build the front-end environment locally and run it, focusing on the back-end Just develop.
-
Download the front-end engineering resource in the resource post and decompress it:
-
Enter
\nginx-1.20.2\html\sky
the path, you can see the packaged project directory structure as follows: -
Then we need to
nginx-1.20.2
move the directory to a directory without Chinese in order to start normally! ! ! -
Double-click
nginx-1.20.2/nginx.exe
the file, the window will flash, and then visit the browser address [ http://localhost/ ]: -
At this point, the front-end environment has been built.
Note: The reverse proxy has been configured in the current Nginx configuration file, through which the front-end request can be forwarded to the back-end service.
Back-end environment construction
project structure
The back-end project is built based on maven and developed in modules. The directory structure of the project is as follows:
Use IDEA to import the initial project, the overall structure of the project is as follows:
Description of the role of each module of the project:
serial number | name | illustrate |
---|---|---|
1 | sky-take-out | Maven parent project, unified management of dependency versions, aggregation of other submodules |
2 | sky-common | Sub-module, storing public classes, such as tool classes, constant classes, exception classes, etc. |
3 | sky-pojo | Sub-module, storing entity classes, VO, DTO, etc. |
4 | sky-server | Sub-modules, back-end services, store configuration files, Controller, Service, Mapper, etc. |
After understanding the overall structure of the project, let's analyze each of the above sub-modules in detail:
sky-common module
The sky-common module stores some public classes that can be used by other modules:
Analyze the role of each package of the sky-common module:
name | illustrate |
---|---|
constant | Store related constant classes |
context | storage context class |
enumeration | Item's enum class storage |
exception | Store custom exception classes |
json | Classes that handle json conversion |
properties | Store SpringBoot related configuration property classes |
result | Returns the encapsulation of the result class |
utils | Common tools |
sky-pojo module
The sky-pojo module stores some entity, DTO, VO classes:
Analyze the role of each package of the sky-pojo module:
name | illustrate |
---|---|
Entity | Entities, usually corresponding to tables in the database |
DTO | Data transfer objects, usually used to transfer data between layers in the program |
VO | View object, the object provided for the front end to display data |
POJO | Ordinary Java objects, only properties and corresponding getters and setters |
sky-server module
The sky-server module stores configuration files, configuration classes, interceptors, controllers, services, mappers, startup classes, etc.:
Analyze the role of each package of the sky-server module:
name | illustrate |
---|---|
config | Storage configuration class |
controller | Store the controller class |
interceptor | store interceptor class |
mapper | store mapper interface |
service | store service class |
SkyApplication | startup class |
Git version control
Create a local repository
-
Click [VCS], [Create Git warehouse]:
-
Select the current project and click OK:
-
The git submit button appears, and the local warehouse is created successfully:
Create a remote repository
-
Visit https://gitee.com/ , create a new warehouse, and improve warehouse information:
-
Click Create:
Push local files to remote warehouse
-
Add remote warehouse address:
-
Click the submit button in the IDEA menu bar:
-
Select [Files without version management], enter the comments for this submission below, and click [Submit and push] [Submit and push anyway]:
-
Click to push:
-
After the push is complete, just refresh the remote warehouse:
Database environment construction
-
Download the database file, [sky.sql]:
-
The database can be created directly through the sql file, so there is no need to create the database in advance, just use SQLYog to import the file and execute it:
-
After the execution is complete, a total of 11 tables are created:
Front-end and back-end joint debugging
The login function has been implemented in the initial project of the backend , and the front-end and back-end joint debugging tests can be performed directly. Implementation idea:
-
Start the front-end environment:
-
Start the backend environment:
-
Enter the account password [account: admin; password: 123456] on the front-end page to log in:
Perfect login function
-
Open the employee table, modify the plaintext password in the database, and change it to 123456 ciphertext encrypted by MD5 [e10adc3949ba59abbe56e057f20f883e]:
-
Modify the code of the user login logic in the EmployeeServiceImpl implementation class, call
DigestUtils
themd5DigestAsHex()
method to encrypt the password submitted by the front end with MD5, and then compare it with the password queried from the database:public Employee login(EmployeeLoginDTO employeeLoginDTO) { ...... //密码比对 // 对前端传过来的明文密码进行MD5加密处理 password = DigestUtils.md5DigestAsHex(password.getBytes()); if (!password.equals(employee.getPassword())) { //密码错误 throw new PasswordErrorException(MessageConstant.PASSWORD_ERROR); } ...... }