Pre-construction of the seckill project

foreword

The resource bloggers in the project will be shared in the resource package synchronously

1. Introduction to the seckill project

project mode

E-commerce model: There are 5 common e-commerce models on the market, B2B, B2C, C2B, C2C, O2O;
1. B2B model
B2B (Business to Business) refers to the business relationship established between merchants. Such as: Alibaba
2, B2C model
B2C (Business to Consumer),
is that we often see suppliers selling goods directly to users, that is, the "business to customer"
model, which is commonly referred to as commercial retail, directly facing consumers Sell ​​products and services. Such as: Suning Tesco, Jingdong,
Tmall, Xiaomi Mall
3, C2B model
C2B (Customer to Business), that is, consumer to business. First there is consumer demand, and then there is enterprise production, that is, first
consumers put forward the demand, and then the production enterprise organizes production
according
to the demand. :Taobao, Xianyu
5, O2O mode
O2O means Online To Offline, which combines offline business opportunities with the Internet, making the Internet the
front desk for offline transactions. Online fast payment, offline high-quality service. Such as: Are you hungry, Meituan, Tao Piao Piao, Jingdong Daojia

Introduction to the technical points of the seckill project

  • frontend html css js jquery freemarker vue
  • Basic javaSE javaEE
  • Framework spring springMVC springBoot mybatis mybatis-plus
  • security shiro (spring security)
  • microservice springCloud springCloud alibaba
  • database mysql
  • test-junit-jmeter

Project basic structure diagram

insert image description here
insert image description here

2. Preliminary environment construction

The main module zmall

Create the main module zmall based on maven in idea, delete the src directory after the creation is successful

insert image description here

Configure pom.xml

1.1 Dependency version locking

<!--依赖版本的锁定-->
<properties>
    <java.version>1.8</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <spring-boot.version>2.3.2.RELEASE</spring-boot.version>
    <spring-cloud.version>Hoxton.SR9</spring-cloud.version>
    <spring-cloud-alibaba.version>2.2.6.RELEASE</spring-cloud-alibaba.version>
</properties>


1.2 configuration of dependency management

<dependencyManagement>
	<dependencies>
        <!-- SpringBoot 依赖配置 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>${
    
    spring-boot.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    	<!--spring-cloud依赖配置-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${
    
    spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <!--spring-cloud-alibaba依赖配置-->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-alibaba-dependencies</artifactId>
            <version>${
    
    spring-cloud-alibaba.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

1.3 Set Maven compilation version

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

1.4 Submodule definition (can be imported after subprojects and public modules are established)

<modules>
    <module>zmall-common</module>
    <module>zmall-user</module>
</modules>

3. zmall-common submodule

  1. Create zmall-common public submodule based on maven. Note: The zmall-common public module only provides dependency support for other modules.
  2. Configure pom.xml
<dependencies>
        <!-- mybatis plus依赖 -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.0</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.44</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.56</version>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-freemarker</artifactId>
        </dependency>
</dependencies>

zmall-user submodule

  1. Create zmall-user user module based on Spring Initialzr method.
  2. Configure pom.xml. Set the parent module and add dependency support for the zmall-common public module
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.zking.zmall</groupId>
        <artifactId>zmall</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <artifactId>zmall-user</artifactId>

    <dependencies>
        <dependency>
            <groupId>com.zking.zmall</groupId>
            <artifactId>zmall-common</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>

Add login page and public resources (js/css/images)

1) After decompressing "Easybuy.com Web Page Materials.zip" in the data directory, add Login.html and js/css/images, etc. to the templates and static directories of the project. It is best to reinstall Login.html Name it login.html

2) Import the common directory in the data directory to the templates directory of the project

3) The head statement in the login.html page is modified to (support H5 style)

4) Import the head.html in the common directory through the <#include> directive in the login.html page

<#include 'common/head.html'>

5) Create UserController and define login.html page jump method

@Controller
public class UserController {
    
    

    @RequestMapping("/login.html")
    public String login(){
    
    
        return "login";
    }
}

The zmall-user structure is as follows
insert image description here
4. Configure application.yml

server:
  port: 8010
spring:
  application:
    name: zmall-user
  datasource:
    #type连接池类型 DBCP,C3P0,Hikari,Druid,默认为Hikari,HikariDataSource属于Mybatisplus依赖
    type: com.zaxxer.hikari.HikariDataSource
    driver-class-name: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/zmall?useUnicode=true&characterEncoding=UTF-8&useSSL=false
    username: root
    password: 123456
  freemarker:
    suffix: .html
    template-loader-path: classpath:/templates/

final rendering

insert image description here

Guess you like

Origin blog.csdn.net/qq_63531917/article/details/128884474