buy cloud server
Smart change of Tencent cloud industry · Cloud inspires the future- Tencent (tencent.com) https://cloud.tencent.com/ Remember to chooseCentOS(based on Linux) operating system
Use XShell to connect to the server
XShell is actually a remote terminal simulation software that allows users to connect to other computers and access and control remote computers in a local terminal window. To put it bluntly, in order to better control the server we bought, a visual interface is provided, and we can access and control the remote computer like a local computer
Right click to create a new session
Install the JDK using the yum command
enter the root directory
cd /
Create a directory called java
mkdir java
Upload the jdk file of the linux version to this directory
It can be managed directly with Xftp , just drag it in
decompress
tar -zxvf jdk-8u111-linux-x64.tar.gz
List all files and directories in the current directory
ls
Delete the installation directory
rm -rf jdk-8u111-linux-x64.tar.gz
Configure environment variables
vi /etc/profile
shift+g cursor to the end of the file
input: i
Insert configuration statement
JAVA_HOME=/java/jdk-17.0.4
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH
:wq saves the current file and exits the editor
Let the environment variable take effect
source /etc/profile
Check whether the jdk installation is successful or not
java -version
project deployment
Dependencies needed for deployment
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.13</version>
<relativePath/>
</parent>
<!--maven的插件 -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<defaultGoal>compile</defaultGoal>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<!--指定启动jar 文件时将执行的Spring Boot 应用程序主类的完全限定名称-->
<mainClass>org.example.Main</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
</dependencies>
Clean up, package the project
Create a new directory and copy the jar package to the server directory
cd command to enter the specified directory (built in the previous step)
ls View all files and directories in the current directory
java -jar xxx run jar package
Finally, remember to add the port to allow external access
The IP address is a unique address used to identify a computer on the Internet. Other computers can communicate with it through the IP address, and the port number is used to uniquely identify a running process or service. If the port on the computer is not open, then the outside world It is not possible to communicate with the computer through this port. When an external computer tries to connect to a computer's port, if the port is not open, the connection request is rejected and an error message is returned. This is because in a computer with an unopened port, there is no process or service listening to the port, so it cannot receive connection requests from the outside. Note that opening too many ports may increase the risk of your computer, as it may expose your computer to more cyber attacks and threats. Therefore, do not open all ports at will