Linux部署Spring Boot Web应用 - Go语言中文社区

Linux部署Spring Boot Web应用


构建一个项目

参考:
building-spring-boot-2-projects-with-gradle

XFTP上传到Linux

配置防火墙

firewall-cmd --zone=public --add-port=8080/http --permanent
firewall-cmd --zone=public --add-service=http --permanent

运行

nohup java -jar gradle-spring-boot-project.jar > hello.log 2>&1 &

gradle-spring-boot-project.jar是我的包名,日志打印到hello.log.

如果成了,就不用看下面了

本人一直有一个疑惑,它的Spring 的一些依赖文件在哪里?
运行:

jar -xvf gradle-spring-boot-project.jar

发现目录结构是这样的:

2019/09/20  15:25    <DIR>          BOOT-INF
2019/09/20  15:25    <DIR>          META-INF
2018/09/12  08:49    <DIR>          org

那个依赖在:BOOT-INFlib下面,可以看下:

在这里插入图片描述

我不知道以后依赖这个东西会不会出问题,但是这给我的Spring boot应用部署提供了一个基本的流程参考。

另外贴出我的gradle代码:

/*
 * This file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java project to get you started.
 * For more details take a look at the Java Quickstart chapter in the Gradle
 * User Manual available at https://docs.gradle.org/5.5.1/userguide/tutorial_java_projects.html
 */

plugins {
    // Apply the java plugin to add support for Java
    id 'java'

    // Apply the application plugin to add support for building a CLI application
    id 'application'
    id 'com.gradle.build-scan' version '2.0.2'
    id 'org.springframework.boot' version '2.0.5.RELEASE'
    id 'io.spring.dependency-management' version '1.0.7.RELEASE'
}

repositories {
    // Use jcenter for resolving dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
    //jcenter { url "http://jcenter.bintray.com/"}
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-dependencies:2.0.5.RELEASE'
    implementation 'org.springframework.boot:spring-boot-starter-web'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'

    components {
        withModule('org.springframework:spring-beans') {
            allVariants {
                withDependencyConstraints {
                    // Need to patch constraints because snakeyaml is an optional dependency
                    it.findAll { it.name == 'snakeyaml' }.each { it.version { strictly '1.19' } }
                }
            }
        }
    }
}

application {
    // Define the main class for the application
    mainClassName = 'hello.App'
}
bootJar {
    mainClassName = 'hello.App'
}

buildScan {

    // always accept the terms of service
    termsOfServiceUrl = 'https://gradle.com/terms-of-service'
    termsOfServiceAgree = 'yes'

    // always publish a build scan
    publishAlways()
}

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/qq_33745102/article/details/101064200
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢