Chris Beams пре 13 година
родитељ
комит
3d91b29b45
2 измењених фајлова са 44 додато и 62 уклоњено
  1. 1
    0
      .gitignore
  2. 43
    62
      README.md

+ 1
- 0
.gitignore Прегледај датотеку

9
 build
9
 build
10
 target
10
 target
11
 dependency-reduced-pom.xml
11
 dependency-reduced-pom.xml
12
+*.sublime-*

+ 43
- 62
README.md Прегледај датотеку

50
 ```xml
50
 ```xml
51
 <?xml version="1.0" encoding="UTF-8"?>
51
 <?xml version="1.0" encoding="UTF-8"?>
52
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
52
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
53
-	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
54
-	<modelVersion>4.0.0</modelVersion>
55
-
56
-	<groupId>org.springframework</groupId>
57
-	<artifactId>gs-rest-service</artifactId>
58
-	<version>0.0.1-SNAPSHOT</version>
59
-
60
-	<parent>
61
-		<groupId>org.springframework.bootstrap</groupId>
62
-		<artifactId>spring-bootstrap-starters</artifactId>
63
-		<version>0.5.0.BUILD-SNAPSHOT</version>
64
-	</parent>
65
-
66
-	<dependencies>
67
-		<dependency>
68
-			<groupId>org.springframework.bootstrap</groupId>
69
-			<artifactId>spring-bootstrap-web-starter</artifactId>
70
-		</dependency>
71
-		<dependency>
72
-			<groupId>com.fasterxml.jackson.core</groupId>
73
-			<artifactId>jackson-databind</artifactId>
74
-		</dependency>
75
-	</dependencies>
76
-
77
-	<!-- TODO: remove once bootstrap goes GA -->
78
-	<repositories>
79
-		<repository>
80
-			<id>spring-snapshots</id>
81
-			<name>Spring Snapshots</name>
82
-			<url>http://repo.springsource.org/snapshot</url>
83
-			<snapshots>
84
-				<enabled>true</enabled>
85
-			</snapshots>
86
-		</repository>
87
-	</repositories>
88
-	<pluginRepositories>
89
-		<pluginRepository>
90
-			<id>spring-snapshots</id>
91
-			<name>Spring Snapshots</name>
92
-			<url>http://repo.springsource.org/snapshot</url>
93
-			<snapshots>
94
-				<enabled>true</enabled>
95
-			</snapshots>
96
-		</pluginRepository>
97
-	</pluginRepositories>
98
-
53
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
54
+    <modelVersion>4.0.0</modelVersion>
55
+
56
+    <groupId>org.springframework</groupId>
57
+    <artifactId>gs-rest-service</artifactId>
58
+    <version>0.0.1-SNAPSHOT</version>
59
+
60
+    <parent>
61
+        <groupId>org.springframework.bootstrap</groupId>
62
+        <artifactId>spring-bootstrap-starters</artifactId>
63
+        <version>0.5.0.BUILD-SNAPSHOT</version>
64
+    </parent>
65
+
66
+    <dependencies>
67
+        <dependency>
68
+            <groupId>org.springframework.bootstrap</groupId>
69
+            <artifactId>spring-bootstrap-web-starter</artifactId>
70
+        </dependency>
71
+        <dependency>
72
+            <groupId>com.fasterxml.jackson.core</groupId>
73
+            <artifactId>jackson-databind</artifactId>
74
+        </dependency>
75
+    </dependencies>
76
+
77
+    <!-- TODO: remove once bootstrap goes GA -->
78
+    <repositories>
79
+        <repository>
80
+            <id>spring-snapshots</id>
81
+            <url>http://repo.springsource.org/snapshot</url>
82
+            <snapshots><enabled>true</enabled></snapshots>
83
+        </repository>
84
+    </repositories>
85
+    <pluginRepositories>
86
+        <pluginRepository>
87
+            <id>spring-snapshots</id>
88
+            <url>http://repo.springsource.org/snapshot</url>
89
+            <snapshots><enabled>true</enabled></snapshots>
90
+        </pluginRepository>
91
+    </pluginRepositories>
99
 </project>
92
 </project>
100
 ```
93
 ```
101
 
94
 
140
 
133
 
141
 
134
 
142
 <a name="initial"></a>
135
 <a name="initial"></a>
143
-
144
 Creating a Representation Class
136
 Creating a Representation Class
145
 -------------------------------
137
 -------------------------------
146
 With the essential Spring MVC configuration out of the way, it's time to get to the nuts and bolts of our REST service by creating a resource representation class and an endpoint controller.
138
 With the essential Spring MVC configuration out of the way, it's time to get to the nuts and bolts of our REST service by creating a resource representation class and an endpoint controller.
181
     public String getContent() {
173
     public String getContent() {
182
     return content;
174
     return content;
183
     }
175
     }
184
-
185
 }
176
 }
186
 ```
177
 ```
187
 
178
 
204
 @Controller
195
 @Controller
205
 @RequestMapping("/hello-world")
196
 @RequestMapping("/hello-world")
206
 public class HelloWorldController {
197
 public class HelloWorldController {
207
-    
198
+
208
     private static final String template = "Hello, %s!";
199
     private static final String template = "Hello, %s!";
209
     private final AtomicLong counter = new AtomicLong();
200
     private final AtomicLong counter = new AtomicLong();
210
 
201
 
211
     @RequestMapping(method=RequestMethod.GET)
202
     @RequestMapping(method=RequestMethod.GET)
212
-    public @ResponseBody Greeting sayHello(@RequestParam(value="name", required=false, defaultValue="Stranger") String name) {
203
+    public @ResponseBody Greeting sayHello(
204
+            @RequestParam(value="name", required=false, defaultValue="Stranger") String name) {
213
         return new Greeting(counter.incrementAndGet(), String.format(template, name));
205
         return new Greeting(counter.incrementAndGet(), String.format(template, name));
214
     }
206
     }
215
-    
216
 }
207
 }
217
 ```
208
 ```
218
 
209
 
258
 
249
 
259
 `pom.xml`
250
 `pom.xml`
260
 ```xml
251
 ```xml
261
-<properties>
262
-	<!-- use UTF-8 for everything -->
263
-	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
264
-	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
265
-	<start-class>hello.HelloWorldConfiguration</start-class>
266
-</properties>
267
-
268
 <build>
252
 <build>
269
     <plugins>
253
     <plugins>
270
         <plugin>
254
         <plugin>
276
 ```
260
 ```
277
 
261
 
278
 The following will produce a single executable JAR file containing all necessary dependency classes:
262
 The following will produce a single executable JAR file containing all necessary dependency classes:
279
-
280
 ```
263
 ```
281
 $ mvn package
264
 $ mvn package
282
 ```
265
 ```
285
 -------------------------------------
268
 -------------------------------------
286
 
269
 
287
 Now you can run it from the jar as well, and distribute that as an executable artifact:
270
 Now you can run it from the jar as well, and distribute that as an executable artifact:
288
-
289
 ```
271
 ```
290
-$ java -jar target/gs-rest-service-0.0.1-SNAPSHOT.jar
272
+$ java -jar target/gs-rest-service-1.0-SNAPSHOT.jar
291
 
273
 
292
 ... service comes up ...
274
 ... service comes up ...
293
 ```
275
 ```
307
 * [Consuming REST services](https://github.com/springframework-meta/gs-consuming-rest-core/blob/master/README.md)
289
 * [Consuming REST services](https://github.com/springframework-meta/gs-consuming-rest-core/blob/master/README.md)
308
 * Testing REST services
290
 * Testing REST services
309
 
291
 
310
-
311
 [zip]: https://github.com/springframework-meta/gs-rest-service/archive/master.zip
292
 [zip]: https://github.com/springframework-meta/gs-rest-service/archive/master.zip