Spring Boot 简单项目部署

Spring Boot 项目部署

添加SpringApplicationBuilder方法

package com.yang;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@EnableSwagger2
@EnableWebSecurity
@SpringBootApplication
public class SpringbootBlogApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(SpringbootBlogApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(this.getClass());
    }
}

创建上线环境远程配置

#远程配置
server:
  port: 8086
spring:
  datasource:
    url: jdbc:mysql://xxx.xxx.xxx:3306/blog?serverTimezone=Asia/Shanghai
    username: yj
    driver-class-name: com.mysql.jdbc.Driver
    # 密文密码
    data-password: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
  thymeleaf:
    cache: false
mybatis:
  type-aliases-package: com.yang.pojo
  mapper-locations: classpath:mapper/*.xml
debug: true

注意事项:1.端口号必须在安全组中开通

​ 2.debug=false

​ 3.数据库连接配置正确

数据库连接navicat配置

在这里插入图片描述

打包springboot文件

在这里插入图片描述

这时就在target文件中得到了jar包

在阿里云上部署

现在所要做的就是将jar包放入ali的linux系统中,首先购买服务器,放通3306,808x端口(依据你在yaml文件中配置的)

我在此使用xftp软件将jar包放入

在这里插入图片描述

在linux中执行java -jar xxx.jar(xxx.jar即为包名),访问 地址:808x即可发现项目已经跑起来

如果显示java 环境未配置,从官网上下载jdk即可

执行nohup java -jar xxx.ja 只要服务器不关闭,项目就不会停止运行。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值