Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy SpringBoot project to server with one click of IDEA

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to deploy a SpringBoot project to a server with one click of IDEA". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Install the Alibaba Cloud Toolkit plug-in

two。 Configure the deployment environment

2.1 set a name for this deployment 2.2 Select how to generate the deployed file

IDEA provides three ways: Maven Build,Upload File,Gradle Build, although my SpringBoot project uses the Maven build tool, I generally choose the Upload File approach. Because my project is a multi-module project, IDEA doesn't know which jar package needs to be uploaded if I choose Maven Build (because its own jar package is generated under each module).

One of the most important things to pay attention to when using Upload File is that we need to manually type a jar package before automatic deployment, so that we can select the jar package we want to upload. This step does not mean that we will upload the files that have just been manually packaged, but just tell IDEA the directory and name of the files to be uploaded later.

The way to pack manually

Then select the jar package you want to upload, as shown in the following figure

2.3 Select target server 2.3.1 has it been configured? Direct selection

If you have previously configured the information of the remote server, just select it and skip the configuration step.

If there is no configuration, then you need to configure it first.

2.3.2 not configured? Then configure the server.

Click the Manage Host button in the lower left corner, and the following interface should pop up at this time. If it does not pop up, just click on the button in the following figure.

Click the Add Host button to fill in your host information

Among them, there are two ways of verification

Password: is to verify your identity by password

Select a Private Key: verify your identity through the local key file

After filling in, click on the status of the test link to see if the link is successful, and click the add button if it is successful; otherwise, check the configuration information until it is successfully added.

After configuring the server information, you can select your host, as shown in the following figure, select it, and then click Select

2.4 fill in the destination directory for file transfer (Target Directory)

Which directory do you want to put the jar in on the server?

2.5 configure After deploy

Judging from the name, this is the action after we set up deploy. IDEA understands that deploy is just uploading the file you want to upload to the server.

Next, click the Select Command button to select the command you want to run, and if you have configured it before, just choose it; if it has not been configured, click the button in the image below and fill in the instructions you want to execute. The instructions here are actually the instructions you run in the terminal, such as executing a script file, or executing some linux built-in commands, etc.

My personal habit is to configure startup scripts, start.sh and stop.sh under the deployed folder

# start.shnohup java-jar zh-sensor-protocol.jar > / dev/null 2 > & 1 & echo "Service started successfully" # stop.shPID=$ (ps-ef | grep zh-sensor-protocol.jar | grep-v grep | awk'{print $2}') if [- z "$PID"] thenecho Application is already stoppedelseecho kill-9$ PIDkill-9$ PIDfi

In this way, I will configure the following command in IDEA

2.6 Before launch

This step refers to what you want to do before the deployment action is officially started. Remember the file we chose to upload before, this step is the key to getting that file.

We click the + button to select the Run Maven Goal option

Then configure the following information, because we choose the Maven option because we are deploying the Spring Boot project, and the deployment of other projects can be flexible.

At this point, we are done with the configuration, and then we can deploy it.

3. Start deployment

Deployment result

This is the end of the introduction of "how to deploy the SpringBoot project to the server with one click of IDEA". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development