[[running-your-application]]
== Running your application with Gradle

To run your application without first building an archive use the `bootRun` task:

[source,bash,indent=0,subs="verbatim"]
----
	$ ./gradlew bootRun
----

The `bootRun` task is automatically configured to use the runtime classpath of the
main source set. By default, the main class will be discovered by looking for a class
with a `public static void main(String[])` method in directories on the task's
classpath. The main class can also be configured explicitly using the task's
`mainClassName` property:

[source,groovy,indent=0,subs="verbatim"]
----
include::../gradle/running/boot-run-main.gradle[tags=main]
----

Alternatively, the main class name can be configured project-wide using the
`mainClassName` property of the Spring Boot DSL:

[source,groovy,indent=0,subs="verbatim"]
----
include::../gradle/running/spring-boot-dsl-main-class-name.gradle[tags=main-class]
----

If the {application-plugin}[`application` plugin] has been applied its `mainClassName`
project property can be used for the same purpose:

[source,groovy,indent=0,subs="verbatim"]
----
include::../gradle/running/application-plugin-main-class-name.gradle[tags=main-class]
----

Two properties, `args` and `jvmArgs`, are also provided for configuring the
arguments and JVM arguments that are used to run the application.

For more advanced configuration the `JavaExecSpec` that is used can be customized:

[source,groovy,indent=0,subs="verbatim"]
----
include::../gradle/running/boot-run-custom-exec-spec.gradle[tags=customization]
----


[[running-your-application-reloading-resources]]
=== Reloading resources
If devtools has been added to your project it will automatically monitor your
application for changes. Alternatively, you can configure `bootRun` such that your
application's static resources are loaded from their source location:

[source,groovy,indent=0,subs="verbatim"]
----
include::../gradle/running/boot-run-source-resources.gradle[tags=source-resources]
----

This makes them reloadable in the live application which can be helpful at development
time.
