A JAR file is a Java Archive. An executable Spring Boot JAR packages an application for running with `java -jar`. The Spring Boot plugin includes dependency libraries on the runtime classpath and writes a manifest that identifies the application's bootstrap class. section 1.2.2
Listing 1.2 The Taco Cloud bootstrap class
package tacos;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication #1
public class TacoCloudApplication {
public static void main(String[] args) {
SpringApplication.run(TacoCloudApplication.class, args); #2
}
}
The bootstrap class has a `main` method that calls `SpringApplication.run`. The JAR's manifest identifies this class as its main class. section 1.2.2
After initializing a Spring Boot project with JAR packaging:
- Run `mvnw package` for a Maven build. Find the resulting JAR in `target`; its name comes from the project's artifact ID and version. section 18.2
- Run `gradlew build` for a Gradle build. Find the JAR in `build/libs`. section 18.2
- Run the built file with `java -jar`. A web application starts its embedded server and listens on its configured port. section 18.2
Deploying Taco Cloud
A built JAR can be pushed to Cloud Foundry with `cf push tacocloud -p target/tacocloud-0.0.19-SNAPSHOT.jar`. An executable JAR suits a PaaS cloud deployment; a traditional Java application server calls for a WAR instead. section 18.2 section 18.1
