Changgou Mall (the first day)

Environment building

Information: Cloud disk connection Extraction code: sb1m

After getting the data, decompress the virtual machine, and open Centos-changgou.vmx with VMware virtual machine software,
Then open, user name: root, password: 123456.
The environment used in the later stage has been installed, so we don't need to waste time to build the environment.
Next, you need to open VMware edit virtual network configuration to open NAT settings

Then click NAT settings to modify IP

Next, enter VI / etc / sysconfig / network scripts / ifcfg-ens33 in the CentOS terminal

reboot restarts the virtual machine, and then you can connect it through ssh tool. ip is password 123456
Then enter the mysql container

docker exec -it mysql /bin/bash

Reset mysql password
Command to open profile first

vi /etc/mysql/my.cnf

Add at the end


Restart msyql

docker restart mysql

Log in again

mysql -uroot -p

Set root password to null

use mysql;

select user,authentication_string,host from user;

Update to empty

update user set authentication_string='' where user='root';

flush privileges;

Exit mysql, execute vi /etc/mysql/my.cnf again, delete and save the previously added content.

Log in using root

mysql -u root

Change password to root

alter user 'root'@'localhost' IDENTIFIED BY 'root';

alter user 'root'@'%' IDENTIFIED BY 'root';

flush privileges;

At this time, your mysql login password can use root login.

navicat connecting database

After the connection is successful, you can see several data tables. Looking at the er chart, we can see that there is no association between tables.

We usually follow three paradigms between slogans when we do projects. However, when we do large projects, we do not recommend three paradigms, but recommend three paradigms instead of three paradigms. It is recommended that we do not create foreign keys, because the speed of adding, deleting and changing will be slower.

Engineering construction

Parent project construction

First, create an empty folder in a directory. I'll name it changgou
Then open the directory through idea, create a module in it, and select mevan

Then finish and add the following to the pom file

        <relativePath/> <!-- lookup parent from repository -->


<!--Dependency package-->
	<!--Test package-->


Second class construction

Create Changgou gateway, Changgou service, Changgou service API
Changgou web project, all projects are pom projects, and the src files of all projects are deleted.

Here, only these are required to be filled with pom packages, and the rest are filled with jar packages.
1. Create Changgou gateway
pom.xml is shown in the figure

2. Create Changgou service
pom.xml is shown in the figure

3. Create Changgou service API

4. Create Changgou Web

The overall structure of the project is shown in the figure

Now the structure of our microservice has been set up

Establishment of Registration Center

Eureka micro service construction

1. Create the module Changgou Eureka
Import pom.xml related dependencies


When the eureka is loaded, the package cannot be imported. It is disgusting.
If not, add a version < version > 2.1.1.release < / version >

Then create application.yml in the resources directory

  port: 6868
    register‐with‐eureka: false #Whether to register yourself in eureka
    fetch‐registry: false #Whether to obtain information from eureka
    name: eureka

2. Create startup class

Then run
Look at the console and tell us the port

Then open the browser to access the port: enter localhost:6868, and the page looks like this

It also tells us that there is no service registration
So far, our registration center has been set up.

Build public modules

pom.xml dependency
Create the common module chaingou common, pom.xml introduces dependency. Under resource / common entity
Related resources import project of

        <!--web Start dependence-->
        <!-- redis Use-->
        <!--WeChat payment-->
        <!--httpclient Support-->

If the spring cloud startup dependency is not imported, add < version > 2.1.1. Release < / version >

Create the com.changgou.entity package, which encapsulates related public entity classes.

package com.changgou.entity;
 * Return result entity class
public class Result<T> {
    private boolean flag;//Success
    private Integer code;//Return code
    private String message;//Return message
    private T data;//Return data
    public Result(boolean flag, Integer code, String message, Object
            data) {
        this.flag = flag;
        this.code = code;
        this.message = message; = (T)data;
    public Result(boolean flag, Integer code, String message) {
        this.flag = flag;
        this.code = code;
        this.message = message;
    public Result() {
        this.flag = true;
        this.code = StatusCode.OK;
        this.message = "Successful implementation";
//getter and setter..

package com.changgou.entity;

import java.util.List;

 * Paging result class
public class PageResult<T> {
    private Long total;//Total number of records
    private List<T> rows;//Record
    public PageResult(Long total, List<T> rows) { = total;
        this.rows = rows;
    public PageResult() {
//getter and setter ......
package com.changgou.entity;

 * Return code
public class StatusCode {
    public static final int OK=20000;//Success
    public static final int ERROR =20001;//fail
    public static final int LOGINERROR =20002;//Wrong user name or password
    public static final int ACCESSERROR =20003;//Insufficient authority
    public static final int REMOTEERROR =20004;//Remote call failed
    public static final int REPERROR =20005;//Repetitive operation
Published 18 original articles, won praise 14, visited 4092
Private letter follow

Tags: MySQL Spring xml CentOS

Posted on Fri, 14 Feb 2020 09:19:00 -0800 by ronald29x