Przeglądaj źródła

Update for Spring Boot 1.2

Dave Syer 9 lat temu
rodzic
commit
e200149662

+ 3
- 1
README.adoc Wyświetl plik

@@ -62,6 +62,8 @@ Here you create an `Application` class with the components:
62 62
 ----
63 63
 include::initial/src/main/java/hello/Application.java[]
64 64
 ----
65
+
66
+`@SpringBootApplication` is a convenience annotation that adds all of the following:
65 67
     
66 68
 - `@Configuration` tags the class as a source of bean definitions for the application context.
67 69
 - `@EnableAutoConfiguration` tells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings.
@@ -235,7 +237,7 @@ It's easy to check the health of the app.
235 237
 
236 238
 ----
237 239
 $ curl localhost:8080/health
238
-ok
240
+{"status":"UP"}
239 241
 ----
240 242
 
241 243
 You can try to invoke shutdown through curl.

+ 2
- 6
complete/src/main/java/hello/Application.java Wyświetl plik

@@ -3,14 +3,10 @@ package hello;
3 3
 import java.util.Arrays;
4 4
 
5 5
 import org.springframework.boot.SpringApplication;
6
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
6
+import org.springframework.boot.autoconfigure.SpringBootApplication;
7 7
 import org.springframework.context.ApplicationContext;
8
-import org.springframework.context.annotation.ComponentScan;
9
-import org.springframework.context.annotation.Configuration;
10 8
 
11
-@Configuration
12
-@EnableAutoConfiguration
13
-@ComponentScan
9
+@SpringBootApplication
14 10
 public class Application {
15 11
     
16 12
     public static void main(String[] args) {

+ 2
- 2
complete/src/test/java/hello/HelloControllerIT.java Wyświetl plik

@@ -1,6 +1,6 @@
1 1
 package hello;
2 2
 
3
-import static org.hamcrest.Matchers.is;
3
+import static org.hamcrest.Matchers.equalTo;
4 4
 import static org.junit.Assert.assertThat;
5 5
 
6 6
 import java.net.URL;
@@ -38,6 +38,6 @@ public class HelloControllerIT {
38 38
 	@Test
39 39
 	public void getHello() throws Exception {
40 40
 		ResponseEntity<String> response = template.getForEntity(base.toString(), String.class);
41
-		assertThat(response.getBody(), is("Greetings from Spring Boot!"));
41
+		assertThat(response.getBody(), equalTo("Greetings from Spring Boot!"));
42 42
 	}
43 43
 }

+ 2
- 2
complete/src/test/java/hello/HelloControllerTest.java Wyświetl plik

@@ -1,6 +1,6 @@
1 1
 package hello;
2 2
 
3
-import static org.hamcrest.Matchers.is;
3
+import static org.hamcrest.Matchers.equalTo;
4 4
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
5 5
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
6 6
 
@@ -32,6 +32,6 @@ public class HelloControllerTest {
32 32
 	public void getHello() throws Exception {
33 33
 		mvc.perform(MockMvcRequestBuilders.get("/").accept(MediaType.APPLICATION_JSON))
34 34
 				.andExpect(status().isOk())
35
-				.andExpect(content().string(is("Greetings from Spring Boot!")));
35
+				.andExpect(content().string(equalTo("Greetings from Spring Boot!")));
36 36
 	}
37 37
 }