我有简单的spring引导应用程序,它作为独立应用程序运行。我开始使用在线指南转换为WAR。Spring引导不会产生战争
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
但没有创造战争。为什么?
'gradlew build'怎么样。 –
是什么让你觉得没有创建战争?你在哪里找它?输出说战争任务已经执行,所以战争应该在'build/distributions /'。 – Vampire
我在build \ libs \ knz-simulator-1.0.0.war中发现了一场战争。这个目标是战争吗? –