Linux system deployment web project

Preface

After learning Java for so long, let us now deploy Java Web projects. The connection tool used is FinalShell, and the project type is Maven project.

Specific steps

1. First, create a SpringBoot project with idea. Configure the view. Then click Maven on the right -> select Lifecycle -> install under the project to be uploaded. The result is as follows (a .jar file is generated)

Insert picture description here

2. In this way, the project is packaged and completed, and then open FinalShell. Choose to upload the packaged jar file

Insert picture description here
3. Enter the command after the file is uploaded ls View uploaded files

4. Then enter the command lsof -i: port numberWhether disconnection is disabled

5. If the input command is disabled kill PID(PID is a string of numbers)

6. Enter the command nohup java -jar jar package -> nohup.out. (Back-end operation)

Insert picture description here

In this way, the project is deployed on Linux. Now visit the page

Insert picture description here

Use the specified application.properties file

In the formal development, there is definitely more than one application.properties configuration file. A project may have many application.properties configuration files such as dev and pro. . Wait, but the project uses the application.properties configuration by default. If I still have an application-dev.properties configuration, and I want to run the dev configuration. At this time, you need to manually specify the configuration

input the commandnohup java -jar test_b-0.0.1-SNAPSHOT.jar -> nohup.out --spring.profiles.active=dev;

At this time, the project uses the dev configuration

Guess you like

Origin blog.csdn.net/javaasd/article/details/109335518