社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
参考:
building-spring-boot-2-projects-with-gradle
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()
}
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!