|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+//
|
|
|
2
|
+// WARNING: DO NOT EDIT THIS FILE unless you are inside the getting-started-macros repo.
|
|
|
3
|
+// For more information see https://github.com/spring-guides/draft-gs-template/wiki/Pull-in-needed-macros
|
|
|
4
|
+// to see how this macro is used for writing Getting Started guides.
|
|
|
5
|
+//
|
|
|
6
|
+:linkattrs:
|
|
|
7
|
+
|
|
|
8
|
+Now that your `Application` class is ready, you simply instruct the build system to create a single, executable jar containing everything. This makes it easy to ship, version, and deploy the service as an application throughout the development lifecycle, across different environments, and so forth.
|
|
|
9
|
+
|
|
|
10
|
+Below are the Gradle steps, but if you are using Maven, you can find the updated pom.xml https://github.com/spring-guides/{project_id}/blob/master/complete/pom.xml[right here] and build it by typing `mvn clean package`.
|
|
|
11
|
+
|
|
|
12
|
+Update your Gradle `build.gradle` file's `buildscript` section, so that it looks like this:
|
|
|
13
|
+
|
|
|
14
|
+[source,java]
|
|
|
15
|
+----
|
|
|
16
|
+buildscript {
|
|
|
17
|
+ repositories {
|
|
|
18
|
+ maven { url "http://repo.spring.io/libs-snapshot" }
|
|
|
19
|
+ mavenLocal()
|
|
|
20
|
+ }
|
|
|
21
|
+ dependencies {
|
|
|
22
|
+ classpath("org.springframework.boot:spring-boot-gradle-plugin:0.5.0.M4")
|
|
|
23
|
+ }
|
|
|
24
|
+}
|
|
|
25
|
+----
|
|
|
26
|
+
|
|
|
27
|
+Further down inside `build.gradle`, add the following to the list of applied plugins:
|
|
|
28
|
+
|
|
|
29
|
+[source,java]
|
|
|
30
|
+apply plugin: 'spring-boot'
|
|
|
31
|
+
|
|
|
32
|
+You can see the final version of `build.gradle` https://github.com/spring-guides/{project_id}/blob/master/complete/build.gradle[right here].
|
|
|
33
|
+
|
|
|
34
|
+The https://github.com/spring-projects/spring-boot/tree/master/spring-boot-tools/spring-boot-gradle-plugin[Spring Boot gradle plugin] collects all the jars on the classpath and builds a single "über-jar", which makes it more convenient to execute and transport your service.
|
|
|
35
|
+It also searches for the `public static void main()` method to flag as a runnable class.
|
|
|
36
|
+
|
|
|
37
|
+Now run the following command to produce a single executable JAR file containing all necessary dependency classes and resources:
|
|
|
38
|
+
|
|
|
39
|
+[subs="attributes"]
|
|
|
40
|
+....
|
|
|
41
|
+$ ./gradlew build
|
|
|
42
|
+....
|
|
|
43
|
+
|
|
|
44
|
+If you are using Gradle, you can run the JAR by typing:
|
|
|
45
|
+
|
|
|
46
|
+[subs="attributes"]
|
|
|
47
|
+....
|
|
|
48
|
+$ java -jar build/libs/{project_id}-0.1.0.jar
|
|
|
49
|
+....
|
|
|
50
|
+
|
|
|
51
|
+If you are using Maven, you can run the JAR by typing:
|
|
|
52
|
+
|
|
|
53
|
+[subs="attributes"]
|
|
|
54
|
+....
|
|
|
55
|
+$ java -jar target/{project_id}-0.1.0.jar
|
|
|
56
|
+....
|
|
|
57
|
+
|
|
|
58
|
+NOTE: The procedure above will create a runnable JAR. You can also opt to link:/guides/gs/convert-jar-to-war/[build a classic WAR file] instead.
|
|
|
59
|
+
|