Reputation: 9474
I have simple spring boot application and it runs as standalone app. I started conversion to WAR using online guides.
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')
}
Initializer:
@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);
}
}
Assembling:
c:\dev\projekty\Simulator>gradlew war
:compileJava
:processResources
:classes
:war
BUILD SUCCESSFUL
Total time: 3.96 secs
But there is no war created. Why?
Upvotes: 3
Views: 5025
Reputation: 113
SpringBoot disable war task. Just re-enable it in the script. I didn't like BootWar which was creating lib-provided folder and other org folder classes for traditional war deployment.
war {
enabled= true
}
Upvotes: 5
Reputation: 15689
In my case, using spring-boot-gradle-plugin:2.0.0.RELEASE
and Gradle 4.2
, for some reason the bootWar
wasn't being triggered by gradlew war
. So, I just executed the command below and the war file was generated:
./gradlew bootWar
Upvotes: 6
Reputation: 38649
The war
is probably generated, just not at the place where you expect it. Add to your build script
logger.lifecycle "war.archivePath = $war.archivePath"
and it will log where you can find the WAR.
Upvotes: 4