gpt4 book ai didi

java - Spring boot 的 gradle 未生成 war

转载 作者:行者123 更新时间:2023-12-02 13:41:35 25 4
gpt4 key购买 nike

我有简单的 Spring Boot 应用程序,它作为独立应用程序运行。我开始使用在线指南转换为 WAR。

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.4.RELEASE")
}
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'war'

bootRun {
addResources = true
}

war {
baseName = 'simulator'
version = '1.0.0'
}

repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile("org.springframework.boot:spring-boot-starter-freemarker")
compile group: 'org.freemarker', name: 'freemarker', version: '2.3.23'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testCompile('org.springframework.boot:spring-boot-starter-test')
}

初始化器:

@SpringBootApplication
public class Application extends SpringBootServletInitializer {

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}

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

组装:

c:\dev\projekty\Simulator>gradlew war
:compileJava
:processResources
:classes
:war
BUILD SUCCESSFUL
Total time: 3.96 secs

但是并没有制造 war 。为什么?

最佳答案

就我而言,使用 spring-boot-gradle-plugin:2.0.0.RELEASEGradle 4.2,由于某种原因 bootWar > 不是由 gradlew war 触发的。所以,我只是执行了下面的命令,war 文件就生成了:

./gradlew bootWar

关于java - Spring boot 的 gradle 未生成 war ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44825608/

25 4 0
文章推荐: c -