Rising Star Project|Project Training|SSM Travel Network Project Combat Notes 1

At the invitation of CSDN, Mr. Zhang, the person in charge of the company's development, was specially appointed to lead the new star project: SSM travel network project training. The relevant notes of the training are now issued in installments for reference. If you need relevant information, you can add WeChat at the end of the blog to get it.

If you want to participate in some project training and improve yourself, you can contact and add it in the text (free learning)

1. Training introduction

Purpose of training: In fact, through actual projects to test everyone's theoretical level and practical level, and at the same time to accumulate corresponding project experience through actual projects.

IT industry: main features---fast changes. But SSM has been used.

Enterprise recruitment: have development experience. One is because of the speed of problem solving. The second is to have a certain technical reserve and strong learning ability.

Through this training you can learn:

1. The basic construction of JAVA enterprise-level development environment: how to install and configure JDK, IDEA, MYSQL5.7, MAVEN, REDIS and other environments.

2. Learning of SSM framework: explaining and learning the development and application of Spring, SpringMvvc, and Mybatis frameworks

3. Learning of Redis cache database: how to use Redis cache database for data caching and optimization

4. Use Alibaba Cloud SMS to send SMS

5. Use WeChat payment SDK to complete online payment

6. Use Baidu's third-party interface to complete map information call and weather information query

7. Complete the front-end function development of a tourism mall based on the SSM framework, and realize the processing steps and development technology of asynchronous interaction between the front and back ends.

Target population:

1. Students who have a certain JAVA learning foundation and front-end HTML, JAVASCRIPT foundation

2. Students who want to work in the IT industry but lack project experience

3. Students who are working on graduation projects and don’t know how to do projects or have projects and don’t know how to answer them


2. Project environment construction

2.1. Project function introduction

Registration, login, logout, category navigation, line page query, line details page, HOT leaderboard, real-name authentication, WeChat scan code payment, SMS verification code and email verification

2.2. Technology selection

 1) Development language java / jdk 1.8 
 2) Development tool IDEA 
 3) Database 
    mysql (relational database) + redis (NoSql database) 
 4) Back-end framework SSM 
      SSM: (spring + springmvc + mybatis) 
 5) Front-end 
      html + css + js + jquery 
 6) SMS verification code service 
     Tencent Cloud-SMS service 
 7) WeChat scan code payment SDK 
 8) jar package management tool maven

2.3. Environment construction

2.3.1 JDK installation and configuration

 Installation reference demo video: https://live.csdn.net/v/282238

 1) Install jdk (after installing JDK, it will submit and then install JRE) 
 2) Configure environment variables 
 3) Run java -version to verify whether it is correct
 Configure environment variables 
 ​1
 ) System variables → Create a new JAVA_HOME variable variable 
   value and fill in the jdk installation directory 
   
 2) System variables → Find the Path variable → Edit and 
    enter %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin at the end of the variable value; 
   (Note Is there a ; number at the end of the original Path variable value, if not, first enter the ; number and then enter the above code)

 For details, see: jdk environment variable configuration document

 The installation of JDK1.8 is divided into two steps: one is to install JDK, and the other is to install JRE. After the installation of JDK, the JRE installation window will pop up automatically, and the next step can be done directly.

 

Configure environment variables:

 Enter the command window of the system to test whether the JDK is installed successfully:

2.3.2 installation of idea

 Reference demo video: https://live.csdn.net/v/282241

 Execute the ideaIU-2020.1.3.exe file and continue to the next step

use

 Find the corresponding version of the PJ file and drag it to the project creation interface

 

idea placement maven

 

2.3.3 maven explain configuration

Maven is a project and package management tool. Before there was no package management tool, we made a Java project that required third-party dependencies. Download the Jar package created by others to the local, and then manually assign it to the project. Troublesome operations, such as version control, what to do if you need a new version, re-download, and re-designate. After using Maven, just add a few lines of xml code in pom.xml, specify the package name, version, etc., for any package you need. In addition, maven also provides many plug-ins, such as commonly used packaging plug-ins, debugging plug-ins, etc., to facilitate our development and deployment.

 

What does maven mainly do

 Project lifecycle management 
 project dependency package management 
 provides a unified project directory structure

maven convention

 

Agreed directory ( unchangeable ):

src/main/java – stores the project's .java files
src/main/resources – stores project resource files. For example, spring, hibernate configuration files
src/test/java – stores all test .java files, such as JUnit test classes
src/test/resources --- test resource files
target --- project output location, put the compiled stuff here
pom.xml -- jar package configuration file

maven life cycle

stage deal with describe
validate validate verification project Verify that the project is correct and all required information is available
compile compile execute compile Source code compilation is done at this stage
Test Test test Run the tests using an appropriate unit testing framework such as JUnit.
packaging package Pack Create JAR/WAR package as defined in pom.xml mentioned package
check verify examine Check the results of integration tests to ensure that the quality is up to standard
install install Install Install the packaged project to the local repository for use by other projects
deploy deploy deploy Copy the final project package to the remote warehouse to share with other developers and projects
 clean Clean up the project cycle

maven repository

 The maven warehouse is the place where all the jar files are placed 
 Local
 warehouse 
   local environment After installing maven, a local warehouse location (.m2/respository/) will be generated, which can be changed in the maven configuration file (recommended) 
 Remote
 Warehouse and central warehouse (the MAVEN team maintains a central warehouse) 
    . When maven finds components that are not in the local warehouse, it needs to download the components from the remote warehouse to the local warehouse for project use. 
    As follows, use the Alibaba Cloud warehouse: 
    When we do not configure a remote warehouse, maven will default to a warehouse, which is the official warehouse of maven, called the central warehouse

maven coordinates

 In mathematics, any coordinate can uniquely determine a "point". 
 Coordinates in Maven are the unique 
 identifiers of Jar packages 
 Coordinate
element describe illustrate
groupId Defines the actual Maven project to which the current module belongs SMEs often correspond directly to companies/organizations
artifactId Define a Maven module in the actual project Uniquely identifies a module
version Define the version of the current project SNAPSHOT indicates an unstable release. LATEST refers to the latest released version, which may be a release version or a snapshot version. RELEASE refers to the last release.
packaging Define Maven project packaging method There are jar (default), war, pom, maven-plugin, etc.

Related configuration of MAVEN:

maven's setting.xml configuration

 maven download: http://maven.apache.org/

1) Specify warehouse location

2) Modify to download from Alibaba Cloud

 <mirror>
     <id>alimaven</id>
     <name>aliyun maven</name>
     <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
     <mirrorOf>central</mirrorOf>
 </mirror>

 

idea placement maven

 

 

Create a simple maven project

 

 

 

 2.3.4 MYSQL explain configuration

 Installation reference demo video: https://live.csdn.net/v/282244

 1, Download and decompress MYSQL5.7

2, Double-click to install MYSQL: mysql-installer-community-5.7.33.0.msi

3. After checking the installation environment: select custom to customize the installation

4. Select the version to install:

5. Check the required environment components for installation:

If it is checked that there are environmental components that need to be installed: it will be installed automatically, just select execute

6. Ready to install:

7. Set administrator password: root

8, the installation is successful

Installed

Modify the encoding configuration:

If the installation path is not modified, the default is: C:\Program Files\MySQL\MySQL Server 5.7

And its data files and configuration files:

Modify the my.ini configuration file and add encoding:

Add below [mysql]:

default-character-set=utf8

You also need to add encoding under [mysqld]:

character-set-server=utf8

Then restart the MYSQL57 service

Execute services.msc on the fly

Check whether the MYSQL service is active

2.4 Introduction to SSM tourism netlist structure

SQL practice:

#添加
INSERT INTO tab_user (uid,username,password,name,birthday,sex,telephone,email,status,code)
VALUES(1,"heima001","abc123456","张三","1999-1-1 16:00:00","男","15812345678","[email protected]","N","123456")

#Account activation
UPDATE tab_user SET status = "Y" , `code` = NULL WHERE `code`= '123456';

#Verify whether the username and password are correct
SELECT * FROM tab_user WHERE username = 'heima001' AND `password` = 'abc123456';

#Category navigation query
SELECT * FROM tab_category ORDER BY cid

#Paging query total number of entries
SELECT COUNT(*) FROM tab_route WHERE cid = 5;

#Paging query SQl
SELECT * FROM tab_route WHERE cid = 5 LIMIT 5,5;

#Route details page
SELECT * FROM tab_route WHERE rid = 1;

SELECT * FROM tab_route_img WHERE rid = 1;

SELECT * FROM tab_seller WHERE sid = 1;

#Create order
INSERT INTO tab_order (orderid,transactionid,payment) VALUES (1,1,'0.01')

#Modify order payment status
UPDATE tab_order SET `status` = 1 , paymenttime = SYSDATE() WHERE orderid = 1;

 

2.5 Redis cache server

1 Introduction

 Redis is an open source high-performance key-value pair (key-value) database developed in C language, where value can be a variety of data structures such as String, hash, list, set, and zset. It can meet many application scenarios. Additional features such as key expiration, publish-subscribe, transactions, pipelining, etc. are also provided.

2) Features

 1. The speed is fast, the data is stored in the memory, and the read and write performance given by the official is 100,000/S (related to the performance of the machine) a. The main reason for the fast speed is that the data is 
     stored in the memory. 
     b. The C language implementation is compatible with the operating system Close distance 
     C. Using a single-threaded architecture to prevent possible competition problems caused by multi-threading 
 2. Data structure server for key-value pairs 
 3. Rich functions 
 4. Simple and stable (single-threaded) 
 5. Persistence: There is data backup to The mechanism of the hard disk. In the event of power failure or machine failure, data will be lost. 
 6. Master-slave replication 
 7. High availability and distribution: Sentinel mechanism to achieve high availability, ensuring redis node failure discovery and automatic transfer 
 8. Client language supports multiple languages: java php python c c++ nodejs

3) Use scenarios

  1. Cache: Reasonable use of cache to speed up data access and reduce pressure on back-end data sources 
  2. Ranking list: Ranked by popularity and release time, mainly using lists and ordered collections 
  3. Counter application: Number of video sites played, Number of website views, etc. 
  4. Social network: like, dislike, fans, pull down to refresh 
  5. Message queue: publish and subscribe 
  6. Other scenarios, etc.

4) Version selection

 1. The second digit of the version number is an odd number, which is an unstable version (2.7, 2.9, 3.1) 
 2. The second digit of the version number is an even number, which is a stable version (2.8, 3.0, 3.2) 
 3. The odd numbered version is the next stable version The development version, such as 2.9 is the development version of 3.0

5) redis is installed under windows system

6) redis start

 Front-end startup: Just run redis-server.exe in the installation directory directly

 

 Backend startup:
  1) Open the cmd window and enter the redis installation directory
  2) Execute redis-server.exe --service-install redis.windows.conf --service-name redis --loglevel verbose
  3) My computer —> right click Select Properties -> Select Services and Applications -> Select Services -> Find redis to start

 

 7) redis client installation

 8) Use the redis client to connect to the redis server

 

9) Operation instructions

string string manipulation instruction

String type: Actually, it can be a string (including XML, JSON), and a number (integer floating point number), binary (picture, audio and video), and the maximum cannot exceed 512MB

 #Storage set value 
 set key value 
 ​#Get
  
 get key 
 ​#Batch
 set value 
 mset key value [key value ...] 
 #Batch get 
 mget key [key ...]
  

hash

It is a mapping table of string type field and value, and hash is especially suitable for storing pairs

#Set value
hset key field value

#Value 
hget key field

#Batch setting
hmset key filed value [filed value ...]

#Batch value
hmget key filed [filed ...]
 
#Get all fields
hkeys key

#Get all value
hvals key

#Get all filed and value
hgetall key

list

Used to store multiple ordered strings. A list can store up to 2 to the 32th power minus 1 element. Because of the order, you can get elements or a list of elements within a certain range through index subscripts. List elements can be repeated

 #Add data to the tail in sequence 
 rpush key value [value ...] 
 ​#Add
 data to the head in sequence 
 lpush key value [value ...] 
 ​#Query
 the elements within the specified subscript range (index subscript: from left to right From 0 to N-1, -1 represents the last element) 
 lrange key start stop 
 ​#Return
 the specified subscript element (index can be negative, -1 represents the last element) 
 lindex key index

set

Save multiple elements. Unlike the list, duplicate elements are not allowed, and the collection is unordered. A collection can store up to 2 to the 32th power minus 1 element

 #Add an element (the same element, the repetition is invalid) 
 sadd key value [value ...] 
 ​#Get
 all value values ​​(return results are unordered) 
 smembers key

check

Ordered set operation instructions, no duplicate elements allowed

 #Add(score) 
 zadd key score member [score member...] 
  
 #Query (elements within the specified subscript range, index subscript: from 0 to N-1, -1 represents the last element) 
 zrange key 0-1 with scores

global

 #View all key 
 keys * 
 ​#View
 the total number of keys 
 dbsize 
 ​#Detect
 if the key exists and return 1, if it does not exist, return 0 
 exists key 
 ​#Delete
 key returns the number of deleted keys, delete the key that does not exist and return 0 
 del key 
 ​#Set
 Expiration time of the key (in seconds) 
 expire key seconds 
 ​#View
 the expiration time of the key (return -1 means no expiration, return -2 means the key does not exist) 
 ttl key 
 ​#View
 the data type of the key (the key does not exist and returns none) 
 type key 
 ​#Get
 the number of client connections 
 info clients

10) Use of redis-Java client

maven

 <dependency>
     <groupId>redis.clients</groupId>
     <artifactId>jedis</artifactId>
     <version>2.6.2</version>
 </dependency>

Create a connection pool - get a connection

 //Create an object in the connection pool and get a redis link from the connection pool 
 JedisPool jedisPool = new JedisPool("127.0.0.1", 6379); 
 Jedis jedis = jedisPool.getResource();

use jedis

 //String
 String set = jedis.set("name", "王五");
 System.out.println(set);
 ​
 String name = jedis.get("name");
 System.out.println(name);
 ​
 ​
 //Hash
 Long hSet = jedis.hset("user:1", "name", "张三");
 System.out.println(hSet);
 ​
 String hName = jedis.hget("user:1", "name");
 System.out.println(hName);
 ​
 ​
 // zAdd
 Long zAdd = jedis.zadd("userZSet", 1, "张三");
 System.out.println(zAdd);
 ​
 Set<Tuple> userZSet = jedis.zrangeWithScores("userZSet", 0, -1);
 System.out.println(userZSet);

2.6 Alibaba Cloud SMS sending

This service integrates all the functions of SMS sending and verification. When sending SMS verification codes, it will connect to the local REDIS, save the verification codes in redis, and return the corresponding information (including the generated key). When verifying The corresponding interface will automatically query redis for comparison, and return the corresponding status code to indicate the success or failure of the verification.

1) environment

 Java 1.8+ redis 
 Alibaba Cloud SMS service

2) Introduction

This project uses Alibaba Cloud SMS service to realize the SMS sending operation. The Alibaba Cloud dependency has been imported into the project, and the tool class SMSTestUtil.java for sending SMS has been written. Students need to refer to the SMS operation document to register on the Alibaba Cloud platform and bind it for testing. Just a mobile phone number. For details, please refer to the Alibaba Cloud SMS sending operation document.

Guess you like

Origin blog.csdn.net/whirlwind526/article/details/129762571