[Huawei Cloud Cloud Server Evaluation] Unbutnu adds SSH Key, compiles and starts Springboot project

Series Article Directory

Chapter 1 [linux actual combat] HUAWEI Yunyao cloud server L instance Java, node environment configuration
Chapter 2 [linux actual combat] Add SSH Key to Unbutnu and start the Springboot project



foreword

In the previous chapter, we configured the JDK, Git, and Node environment in the Unbutnu system of Yunyao Cloud Server. In this chapter, we need to add the SSH Key, pull the Springboot project on github, compile it through Maven, and finally run it.


1. Task dismantling

1. Add SSH Key;
2. Pull the Springboot project on github through the git command;
3. Compile the project through Maven;
4. Run the project

2. Configure git and add SSH Key

2.1. Log in to the remote host

Open the terminal and enter the command to configure:

ssh root@remote host external network IP
input password

2.2. Configure git username and email

Enter the command in the terminal to configure:

git config --global user.name 'username'
git config --global user.email '[email protected]'

2.3. Generate SSH key

Enter the command in the terminal to generate an SSH key:

ssh-keygen -t rsa -C ’[email protected]
insert image description here

2.4. Check the generated SSH key

Enter the command in the terminal to view the SSH key:

cat /root/.ssh/icsdnQc_rsa.pub
insert image description here

2.5. Add SSH key in github

Paste the information in the xx.pub file generated by [2.4] into the SSH Key in github
insert image description here

3. Pull the Springboot project on github through the git command

3.1. Prepare the Springboot project and upload it to github

Demo address (private project): https://github.com/hd5723/csdnQc.git

3.2. Pull code

See [2.5] SSH key needs to be configured in advance

cd /home //Enter home directory
mkdir java //Create java directory
cd java //Enter java directory
mkdir code //Create code directory
cd code //Enter code directory
git clone https://github.com/hd5723/csdnQc. git //Pull the code from the github warehouse
insert image description here
The screenshot is the created /home/java/code directory, the csdnQc code that has been pulled down, open the csdnQc, you can see the Java project structure: pom.xml, src

4. Compile the project through Maven

4.1. Configure the Ali image of maven

4.1.1. Check the maven configuration and find the path of maven in the host

Enter the command in the terminal:

mvn -v
insert image description here

4.1.2. Enter the Maven home path in the previous step and find the settings.xml file

Enter the command in the terminal:

cd /usr/share/maven
ls
cd conf
ls
insert image description here

4.2. Modify the settings.xml file

Edit the settings.xml file through the VI command, and add the code inside the mirrors tag:

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

insert image description here

5. Run the project

5.1. Package Springboot project

Enter the command in the terminal:

cd /home/java/code/csdnQc/ //Enter the project directory
mvn clean package //Use the mvn command to compile and package the project
insert image description here
insert image description here

ls
cd target //Enter the target directory (compiled files)
ls //Check the files in the target directory, if the compilation is successful, you can see the xxxx-xxx-SNAPSHOT.jar file
insert image description here

5.2, run the project

Enter the command in the terminal:

nohup java -jar spiderX-0.0.1-SNAPSHOT.jar >log.file 2>&1 &
insert image description here

5.2.1, view the project through the browser

Address: http://139.159.230.49/static/index.html
1. The project has done a simple CSDN blog quality sub-query (local cache, not cleaned);
2. No permission verification;
3. The first input box It is the CSDN account ID
to find my random blog: https://blog.csdn.net/s445320/article/details/132556690
Case: s445320 is my own account ID
4. The first input box is the page number (default every Page 100 data, no multi-thread optimization, so the interface is very slow)
insert image description here

6. Summary

The above is the content of this chapter. We pull our Springboot code from github to the ubuntu cloud host through the git command, then package the project through the mvn command, and finally run the project, and access the project through a browser (if the access is not, Please refer to the network security group configuration in the previous chapter, you need to configure ingress rules and open port 80)

Guess you like

Origin blog.csdn.net/s445320/article/details/132609542
Recommended