我有簡單的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中發現了一場戰爭。這個目標是戰爭嗎? –