64.3 Packaging executable jar and war files
Once the spring-boot plugin has been applied to your project it will automatically attempt to rewrite archives to make them executable using the bootRepackage task. You should configure your project to build a jar or war (as appropriate) in the usual way.
The main class that you want to launch can either be specified using a configuration option, or by adding a Main-Class attribute to the manifest. If you don’t specify a main class the plugin will search for a class with a public static void main(String[] args) method.
![]() |
Tip |
|---|---|
| Check Section 64.6, “Repackage configuration” for a full list of configuration options. |
To build and run a project artifact, you can type the following:
$ gradle build $ java -jar build/libs/mymodule-0.0.1-SNAPSHOT.jar
To build a war file that is both executable and deployable into an external container, you need to mark the embedded container dependencies as belonging to the war plugin’s providedRuntime configuration, e.g.:
...
apply plugin: 'war'
war {
baseName = 'myapp'
version = '0.5.0'
}
repositories {
jcenter()
maven { url "http://repo.spring.io/libs-snapshot" }
}
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
...
}
![]() |
Tip |
|---|---|
| See the “Section 81.1, “Create a deployable war file”” section for more details on how to create a deployable war file. |
![[Tip]](Spring Boot Reference Guide_files/tip.png)