Linux server deploys springboot project

1. Create a springboot project through idea

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

Pay attention to the maven configuration modification, the default is the c drive

2. Create a test interface

package com.geekmice.demospringboot.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {
    
    

    @RequestMapping("success")
    public String success(){
    
    
        return "success";
    }
}

3. Springboot project packaging jar

mvn clean package

insert image description here
4. Log in to the server to create a project directory

mkdir demospringbot

insert image description here
Enter the demospringboot project directory, upload the jar that was just packaged to this directory
insert image description here
and create a nohup.out log file to output the log output of project startup

touch nohup.out

run jar file

nohup java -jar demo-0.0.1-SNAPSHOT.jar
nohup java -jar demo-0.0.1-SNAPSHOT.jar --server.port=8080 -- 指定端口号启动
nohup java -jar demo-0.0.1-SNAPSHOT.jar --spring.profiles.active=prod
-- 指定配置文件启动

View the log file nohup.out

tail -f nohup.out

Configure other environments required by the project
Open the port number for the project to run (check the port development status: firewall-cmd --list-ports)

firewall-cmd --zone=public --add-port=8080/tcp --permanent

restart firewall

systemctl reload firewalld

external access

http://4.3.2.1:8080/success

insert image description here

Guess you like

Origin blog.csdn.net/greek7777/article/details/127261081