Преглед изворни кода

Update for Spring Boot 1.2

Dave Syer пре 11 година
родитељ
комит
e200149662

+ 3
- 1
README.adoc Прегледај датотеку

62
 ----
62
 ----
63
 include::initial/src/main/java/hello/Application.java[]
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
 - `@Configuration` tags the class as a source of bean definitions for the application context.
68
 - `@Configuration` tags the class as a source of bean definitions for the application context.
67
 - `@EnableAutoConfiguration` tells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings.
69
 - `@EnableAutoConfiguration` tells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings.
235
 
237
 
236
 ----
238
 ----
237
 $ curl localhost:8080/health
239
 $ curl localhost:8080/health
238
-ok
240
+{"status":"UP"}
239
 ----
241
 ----
240
 
242
 
241
 You can try to invoke shutdown through curl.
243
 You can try to invoke shutdown through curl.

+ 2
- 6
complete/src/main/java/hello/Application.java Прегледај датотеку

3
 import java.util.Arrays;
3
 import java.util.Arrays;
4
 
4
 
5
 import org.springframework.boot.SpringApplication;
5
 import org.springframework.boot.SpringApplication;
6
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
6
+import org.springframework.boot.autoconfigure.SpringBootApplication;
7
 import org.springframework.context.ApplicationContext;
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
 public class Application {
10
 public class Application {
15
     
11
     
16
     public static void main(String[] args) {
12
     public static void main(String[] args) {

+ 2
- 2
complete/src/test/java/hello/HelloControllerIT.java Прегледај датотеку

1
 package hello;
1
 package hello;
2
 
2
 
3
-import static org.hamcrest.Matchers.is;
3
+import static org.hamcrest.Matchers.equalTo;
4
 import static org.junit.Assert.assertThat;
4
 import static org.junit.Assert.assertThat;
5
 
5
 
6
 import java.net.URL;
6
 import java.net.URL;
38
 	@Test
38
 	@Test
39
 	public void getHello() throws Exception {
39
 	public void getHello() throws Exception {
40
 		ResponseEntity<String> response = template.getForEntity(base.toString(), String.class);
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 Прегледај датотеку

1
 package hello;
1
 package hello;
2
 
2
 
3
-import static org.hamcrest.Matchers.is;
3
+import static org.hamcrest.Matchers.equalTo;
4
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
4
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
5
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
5
 import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
6
 
6
 
32
 	public void getHello() throws Exception {
32
 	public void getHello() throws Exception {
33
 		mvc.perform(MockMvcRequestBuilders.get("/").accept(MediaType.APPLICATION_JSON))
33
 		mvc.perform(MockMvcRequestBuilders.get("/").accept(MediaType.APPLICATION_JSON))
34
 				.andExpect(status().isOk())
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
 }