|
|
@@ -50,7 +50,9 @@ In a project directory of your choosing, create the following subdirectory struc
|
|
50
|
50
|
└── java
|
|
51
|
51
|
└── hello
|
|
52
|
52
|
|
|
|
53
|
+
|
|
53
|
54
|
### Create a Gradle build file
|
|
|
55
|
+Below is the [initial Gradle build file](https://github.com/springframework-meta/gs-spring-boot/blob/master/initial/build.gradle). But you can also use Maven. The pom.xml file is included [right here](https://github.com/springframework-meta/gs-spring-boot/blob/master/initial/pom.xml).
|
|
54
|
56
|
|
|
55
|
57
|
`build.gradle`
|
|
56
|
58
|
```gradle
|
|
|
@@ -88,6 +90,8 @@ task wrapper(type: Wrapper) {
|
|
88
|
90
|
gradleVersion = '1.7'
|
|
89
|
91
|
}
|
|
90
|
92
|
```
|
|
|
93
|
+
|
|
|
94
|
+
|
|
91
|
95
|
|
|
92
|
96
|
Learn what you can do with Spring Boot
|
|
93
|
97
|
--------------------------------------
|
|
|
@@ -184,6 +188,12 @@ To run the application, execute:
|
|
184
|
188
|
$ ./gradlew build && java -jar build/libs/gs-spring-boot-0.1.0.jar
|
|
185
|
189
|
```
|
|
186
|
190
|
|
|
|
191
|
+If you are using Maven, execute:
|
|
|
192
|
+
|
|
|
193
|
+```sh
|
|
|
194
|
+$ mvn package && java -jar target/gs-spring-boot-0.1.0.jar
|
|
|
195
|
+```
|
|
|
196
|
+
|
|
187
|
197
|
You should see some output like this:
|
|
188
|
198
|
|
|
189
|
199
|
```sh
|
|
|
@@ -237,12 +247,21 @@ Switch from Tomcat to Jetty
|
|
237
|
247
|
---------------------------
|
|
238
|
248
|
What if you prefer Jetty over Tomcat? Jetty and Tomcat are both compliant servlet containers, so it should be easy to switch. With Spring Boot, it is!
|
|
239
|
249
|
|
|
240
|
|
-Add this to your build file's list of dependencies:
|
|
|
250
|
+Add this to your `build.gradle` list of dependencies:
|
|
241
|
251
|
|
|
242
|
252
|
```groovy
|
|
243
|
253
|
compile("org.springframework.boot:spring-boot-starter-jetty:0.5.0.BUILD-SNAPSHOT")
|
|
244
|
254
|
```
|
|
245
|
255
|
|
|
|
256
|
+If you are using Maven, add this to your list of dependencies:
|
|
|
257
|
+
|
|
|
258
|
+```xml
|
|
|
259
|
+ <dependency>
|
|
|
260
|
+ <groupId>org.springframework.boot</groupId>
|
|
|
261
|
+ <artifactId>spring-boot-starter-jetty</artifactId>
|
|
|
262
|
+ </dependency>
|
|
|
263
|
+```
|
|
|
264
|
+
|
|
246
|
265
|
Add multipart upload support
|
|
247
|
266
|
-------------------------------
|
|
248
|
267
|
Suppose you want to add file upload support. To do that, update your configuration by adding a `MultipartConfigElement` to the application context.
|
|
|
@@ -300,6 +319,12 @@ Run the app again:
|
|
300
|
319
|
$ ./gradlew build && java -jar build/libs/gs-spring-boot-0.1.0.jar
|
|
301
|
320
|
```
|
|
302
|
321
|
|
|
|
322
|
+If you are using Maven, execute:
|
|
|
323
|
+
|
|
|
324
|
+```sh
|
|
|
325
|
+$ mvn package && java -jar target/gs-spring-boot-0.1.0.jar
|
|
|
326
|
+```
|
|
|
327
|
+
|
|
303
|
328
|
Now check out the output:
|
|
304
|
329
|
|
|
305
|
330
|
```sh
|
|
|
@@ -359,12 +384,27 @@ Add this to your build file's list of dependencies:
|
|
359
|
384
|
compile("org.springframework.boot:spring-boot-starter-actuator:0.5.0.BUILD-SNAPSHOT")
|
|
360
|
385
|
```
|
|
361
|
386
|
|
|
|
387
|
+If you are using Maven, add this to your list of dependencies:
|
|
|
388
|
+
|
|
|
389
|
+```xml
|
|
|
390
|
+ <dependency>
|
|
|
391
|
+ <groupId>org.springframework.boot</groupId>
|
|
|
392
|
+ <artifactId>spring-boot-starter-actuator</artifactId>
|
|
|
393
|
+ </dependency>
|
|
|
394
|
+```
|
|
|
395
|
+
|
|
362
|
396
|
Then restart the app:
|
|
363
|
397
|
|
|
364
|
398
|
```sh
|
|
365
|
399
|
$ ./gradlew build && java -jar build/libs/gs-spring-boot-0.1.0.jar
|
|
366
|
400
|
```
|
|
367
|
401
|
|
|
|
402
|
+If you are using Maven, execute:
|
|
|
403
|
+
|
|
|
404
|
+```sh
|
|
|
405
|
+$ mvn package && java -jar target/gs-spring-boot-0.1.0.jar
|
|
|
406
|
+```
|
|
|
407
|
+
|
|
368
|
408
|
You will see a new set of RESTful end points added to the application. These are management services provided by Spring Boot.
|
|
369
|
409
|
|
|
370
|
410
|
```sh
|