在云服务器上部署Springboot项目

1.本地项目打包

利用IDEA中的Maven对项目打包。

注意:

1. Springboot项目一般会内置tomcat

2.如果项目有一些外部依赖的jar包(比如opengauss-jdbc-5.0.0.jar),如何把它打包进去?

参考文章

①引入外部依赖(外部依赖放在自己建的libs目录中)

<dependency>
  <groupId>com.xxx.www</groupId>
  <artifactId>out-jar-1</artifactId>
  <version>1.0.0</version>
  <scope>system</scope>
  <systemPath>${project.basedir}/libs/commons-cxxxx.jar</systemPath>
</dependency>

②加一句:“<includeSystemScope>true</includeSystemScope>”

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <includeSystemScope>true</includeSystemScope>
    </configuration>
</plugin>

3.配置application.yml,注意datasource和server.address=0.0.0.0,示例如下。

server:
  port: 8080
  address: 0.0.0.0


spring:
  datasource:
    driver-class-name: org.opengauss.Driver
    url: jdbc:opengauss://xx.xx.xx.xx:5432/medicine_manage
    username: xxx
    password: xxxx
    type: com.alibaba.druid.pool.DruidDataSource
  mvc:
    static-path-pattern: /static/**
  thymeleaf:
    prefix: classpath:/templates
    cache: false

2.云服务器配置

①安装java

Linux系统下安装Java环境(史上最简单没有之一)_linux下载java-CSDN博客

Linux 下,jdk11 没有 jre 解决办法_linux jdk11没有jre-CSDN博客

② 布置好自己的数据库

③ 后台运行项目

nohup -jar ./xxxx.jar > log.txt &

④可以看看日志,项目是否正常运行

cat log.txt

查看8080端口是否处于监听状态(前提:配置一下云服务器的安全组,保证8080端口是放行的)

netstat -nltp | grep 8080

3.其它资料

Java -jar启动服务与Tomcat服务器上部署JAR之间的区别_jar运行和tomcat部署区别-CSDN博客

相关推荐

  1. 服务器部署Springboot项目

    2023-12-15 06:42:01       49 阅读
  2. 如何服务器部署springboot项目

    2023-12-15 06:42:01       40 阅读
  3. 服务器部署SpringBoot项目jar包

    2023-12-15 06:42:01       39 阅读
  4. Docker部署SpringBoot项目服务器

    2023-12-15 06:42:01       42 阅读
  5. Docker部署Springboot项目

    2023-12-15 06:42:01       43 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-15 06:42:01       17 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-15 06:42:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-15 06:42:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-15 06:42:01       18 阅读

热门阅读

  1. 大语言模型--危害

    2023-12-15 06:42:01       40 阅读
  2. Python中的内存泄漏及其检测方法

    2023-12-15 06:42:01       42 阅读