The hottest Nacos source code build in the whole network, you can't find the second one that I'm careful! !

This chapter starts with you to build the Nacos source code. Later I will start to analyze the details of the Nacos source code, combining the bits and pieces of Nacos I use in my spare time. If you want to learn Nacos with me, just

Take a good look at this article, don't talk nonsense, let me tell you how to build Nacos through tools! ! !

1. Environmental preparation

Idea version: whatever you want
Maven version: maven3.5.x and above! ! ! It must be noted here that inexplicable problems may occur in the lower version!
Nacos version: stable version 1.4.2, address: https://gitee.com/mirrors/Nacos/tree/1.4.2
Protoc version: 3.17.2 of the windows version, address: https://github.com/protocolbuffers/protobuf/releases
Java version: 1.8, don’t change it into other versions here
Below is the screenshot:
nacos:
protoc version:

2. Build Nacos source code

After downloading the Nacos source package, unzip it to any directory of yours and open it with Idea
File——>Open——> the pom file in the root directory of your Nacos source code——>Open as project
After opening, you need to find a project called console, click on the main startup class inside to start it
Oh, I got an error, all kinds of categories can't be found. . .
When I first looked at it, I thought it was silly? If you download it, you will make mistakes like not finding the class? Later I found out that I was naive. . .
At the beginning, remember that I asked everyone to download a Protoc package, which is used to generate .protoc files and convert them into java files! ! The reason for this is because the proto file is used in nacos, and the corresponding entity class is not generated in the code, so we need to generate it manually.

3. Install Protoc environment variables

Protoc, you don’t have to worry about what this is. Your goal now is to build this environment, so find the Protoc version you downloaded and unzip it to your favorite directory.
Then configure the environment variables, the path is under the bin directory of your Protoc! !
Then we execute cmd after opening
protoc --version
The configuration is successful! ! !
Next, go to the consistency/src/main/proto/ path of the source code, use the cmd command, and run the following commands
protoc --java_out=../java/ ./consistency.proto protoc --java_out=../java/ ./Data.proto
The result of running is like this:
At this time, it means that the generation of protoc files to java files has been completed! ! ! !

4. Configure database information

In fact, if you don't need to understand the source code of the configuration center, the first three steps will be enough for you.
But we are not limited to this, so it is necessary to configure the database, because the configuration needs to be persistent, otherwise, if you restart, all the online configuration will be lost. . . .
Create a database in the local Mysql called nacos_config. In fact, you will know why I know when you open this project!
So after you create the database, paste this script into it and execute it, and the result is like this.
We also need to modify the data source!
To modify the database connection part in the application.properties file in the project, you need to modify the distribution/conf/ file application.properties, and the application.properties under resources in the console project, as shown below:
Then it is the last step to start! !

5. Stand-alone startup

The stand-alone startup method is:
Add -Dnacos.standalone=ture
That's it! ! Visit localhost:8080/nacos

Welcome to the comment area with one click and three links! ! !