gpt4 book ai didi

java - 使用gradle从spring boot 1.5.3构建可执行文件.jar

转载 作者:行者123 更新时间:2023-12-03 05:42:45 25 4
gpt4 key购买 nike

我有一个spring boot项目(1.5.3版本),并使用gradle 4.4。
我将构建一个.jar可执行文件,以在Linux服务器上安装服务。
但我在生成可执行.jar文件时遇到问题。

  buildscript {
ext {
springBootVersion = '1.5.8.RELEASE'
//springBootVersion = '2.0.3.RELEASE'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'application'

springBoot {
executable = true
}

group = 'com.mygroup'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}


dependencies {
compile('org.springframework.boot:spring-boot-starter-data-jpa')
compile('org.springframework.boot:spring-boot-starter-security')
compile('org.springframework.boot:spring-boot-starter-thymeleaf')
compile("org.springframework.boot:spring-boot-starter-web")
compile('org.thymeleaf.extras:thymeleaf-extras-springsecurity4')
compile group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.371'
compile group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: '1.11.370'
runtime('org.springframework.boot:spring-boot-devtools')
runtime('mysql:mysql-connector-java')
testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.security:spring-security-test')
testCompile('com.jayway.jsonpath:json-path')

}

我如何生成.jar?

最佳答案

引导 jar 缺少相关性。

在build.gradle中添加:

bootJar {
baseName = 'application-name'
version = '1.0.0'
}

终端中的命令:
gradle bootjar

关于java - 使用gradle从spring boot 1.5.3构建可执行文件.jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51749124/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com