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