|
|
@@ -276,10 +276,37 @@ Now you can run it from the jar as well, and distribute that as an executable ar
|
|
276
|
276
|
```
|
|
277
|
277
|
$ java -jar target/gs-rest-service-1.0.jar
|
|
278
|
278
|
|
|
279
|
|
-... service comes up ...
|
|
|
279
|
+```
|
|
|
280
|
+
|
|
|
281
|
+
|
|
|
282
|
+Test the service
|
|
|
283
|
+----------------
|
|
|
284
|
+
|
|
|
285
|
+Once the service starts, you can test it by pointing your web browser at http://localhost:8080/hello-world. Or you can consume it from the command line using [`curl`][curl]:
|
|
|
286
|
+
|
|
|
287
|
+```
|
|
|
288
|
+$ curl http://localhost:8080/hello-world
|
|
|
289
|
+```
|
|
|
290
|
+
|
|
|
291
|
+Either way, the response should look like this:
|
|
|
292
|
+```
|
|
|
293
|
+{"id":1,"content":"Hello, World!"}
|
|
|
294
|
+```
|
|
|
295
|
+
|
|
|
296
|
+Now try providing a `name` query string parameter: http://localhost:8080/hello-world?name=User
|
|
|
297
|
+
|
|
|
298
|
+```
|
|
|
299
|
+$ curl http://localhost:8080/hello-world?name=User
|
|
|
300
|
+```
|
|
|
301
|
+
|
|
|
302
|
+And notice how the content changes:
|
|
|
303
|
+
|
|
|
304
|
+```
|
|
|
305
|
+{"id":1,"content":"Hello, User"}
|
|
280
|
306
|
```
|
|
281
|
307
|
|
|
282
|
308
|
Congratulations! You have just developed a simple RESTful service using Spring. This is a basic foundation for building a complete REST API in Spring.
|
|
283
|
309
|
|
|
284
|
310
|
[zip]: https://github.com/springframework-meta/gs-rest-service/archive/master.zip
|
|
285
|
311
|
[jdk7]: http://docs.oracle.com/javase/7/docs/webnotes/install/index.html
|
|
|
312
|
+[curl]: http://curl.haxx.se/download.html
|