current position:Home>[Deployment] Deploy the back-end project to the Pagoda Linux cloud server Java SpringBoot

[Deployment] Deploy the back-end project to the Pagoda Linux cloud server Java SpringBoot

2022-08-06 17:28:22peach

1. 配置宝塔

  1. 下载宝塔
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh
  1. Save the account password given by Pagoda

在这里插入图片描述

  1. Copy the intranet link,Go to pagoda page,下载mysql、tomcat、PHP、phpadmin

  2. 端口放行 :宝塔+云服务器
    在这里插入图片描述
    在这里插入图片描述

2. 配置java文件

2.1 application.yml

If you need to upload files to the directory,在application.yml中配置:
在这里插入图片描述
在这里插入图片描述

2.2 web config Map root path address

在这里插入图片描述

在这里插入图片描述

2.3 解决跨域问题

参考文章

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfigure implements WebMvcConfigurer {
    

  @Value("${CROS_MAPPING}")
  private String mapping;

  @Value("${CROS_ALLOWED_ORIGINS}")
  private String[] allowedOrigins;

  @Value("${CROS_ALLOWED_METHOD}")
  private String[] allowedMethods;

  @Override
  public void addCorsMappings(CorsRegistry registry) {
    
    registry.addMapping(mapping).allowedOrigins(allowedOrigins).allowedMethods(allowedMethods).allowCredentials(true);
  }
}

配置文件
在resource里面配置springbootConfiguration file for basic configuration(application.properties,也可以是别的,See which file your project is configured with)里面加入以下配置,根据自己的需要配置.in the previous [email protected] can read the configuration below.

CROS_MAPPING=/**
CROS_ALLOWED_ORIGINS=http://localhost:81,http://localhost:8080
CROS_ALLOWED_METHOD=OPTIONS,GET,POST,DELETE,PUT

3. 上传数据库

  1. navicat存储sql文件
    在这里插入图片描述

  2. 将sqlImport the file into Pagoda,Then import it into the corresponding database

在这里插入图片描述

4. 上传工程

在这里插入图片描述

5. 开启工程

  1. cd进jar包所在目录
  2. 开启工程
下面两个二选一:

The first note cannot be cut outterminal,Otherwise it will be disconnected,But you can see the running log intuitively
java -jar ruoyiadmin.jar 

The second cut out is also running all the time,But can't see the log of the run,Logs are written automaticallynohup.out文件
nohup java -jar ruoyiadmin.jar &

bug解决

The error port is in use-解决方案

看一下使用情况

pgrep -list "java"

See which one is using that port numberpid

kill -9 对应的pid

phpadminPlug-in download error solution

https://techglimpse.com/failed-metadata-repo-appstream-centos-8/

copyright notice
author[peach],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/218/202208061704447510.html

Random recommended