diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EndpointMvcAdapter.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EndpointMvcAdapter.java index b3b4a7a199fa..36874d403d13 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EndpointMvcAdapter.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EndpointMvcAdapter.java @@ -18,8 +18,7 @@ import org.springframework.boot.actuate.endpoint.Endpoint; import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; /** @@ -39,7 +38,7 @@ public EndpointMvcAdapter(Endpoint delegate) { } @Override - @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public Object invoke() { return super.invoke(); diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpoint.java index 6de5236f3496..840232405af7 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpoint.java @@ -26,9 +26,8 @@ import org.springframework.core.env.PropertySources; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; @@ -49,7 +48,7 @@ public EnvironmentMvcEndpoint(EnvironmentEndpoint delegate) { super(delegate); } - @RequestMapping(value = "/{name:.*}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(value = "/{name:.*}", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody @HypermediaDisabled public Object value(@PathVariable String name) { diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/MetricsMvcEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/MetricsMvcEndpoint.java index ea87cffb8539..ccaed3f6e5e7 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/MetricsMvcEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/MetricsMvcEndpoint.java @@ -22,9 +22,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; @@ -45,7 +44,7 @@ public MetricsMvcEndpoint(MetricsEndpoint delegate) { this.delegate = delegate; } - @RequestMapping(value = "/{name:.*}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(value = "/{name:.*}", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody @HypermediaDisabled public Object value(@PathVariable String name) { diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpoint.java index 2d044c784d76..0ecfab439286 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpoint.java @@ -23,8 +23,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.ResponseBody; /** @@ -39,7 +38,7 @@ public ShutdownMvcEndpoint(ShutdownEndpoint delegate) { super(delegate); } - @RequestMapping(method = RequestMethod.POST) + @PostMapping @ResponseBody @Override public Object invoke() { diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EndpointHandlerMappingTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EndpointHandlerMappingTests.java index 762359bfad49..8e162f97f4d3 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EndpointHandlerMappingTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EndpointHandlerMappingTests.java @@ -27,8 +27,7 @@ import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.util.ReflectionUtils; import org.springframework.web.HttpRequestMethodNotSupportedException; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.method.HandlerMethod; import static org.assertj.core.api.Assertions.assertThat; @@ -168,7 +167,7 @@ private static class TestActionEndpoint extends EndpointMvcAdapter { } @Override - @RequestMapping(method = RequestMethod.POST) + @PostMapping public Object invoke() { return null; } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java index 45cda8d0ba20..3a208e0a0ed4 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java @@ -90,8 +90,8 @@ import org.springframework.test.util.ReflectionTestUtils; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; @@ -191,7 +191,8 @@ public void testClientIsNotAuthCode() { EnvironmentTestUtils.addEnvironment(context, "security.oauth2.client.clientId=client"); context.refresh(); - assertThat(countBeans(context, ClientCredentialsResourceDetails.class)).isEqualTo(1); + assertThat(countBeans(context, ClientCredentialsResourceDetails.class)) + .isEqualTo(1); context.close(); } @@ -465,13 +466,13 @@ protected static class ResourceServerConfiguration extends TestSecurityConfigura @RestController protected static class TestWebApp { - @RequestMapping(value = "/securedFind", method = RequestMethod.GET) + @GetMapping("/securedFind") @PreAuthorize("#oauth2.hasScope('read')") public String secureFind() { return "You reached an endpoint secured by Spring Security OAuth2"; } - @RequestMapping(value = "/securedSave", method = RequestMethod.POST) + @PostMapping("/securedSave") @PreAuthorize("#oauth2.hasScope('write')") public String secureSave() { return "You reached an endpoint secured by Spring Security OAuth2"; diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/BasicErrorControllerIntegrationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/BasicErrorControllerIntegrationTests.java index 3fce29961b88..59dec7f769f7 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/BasicErrorControllerIntegrationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/BasicErrorControllerIntegrationTests.java @@ -49,9 +49,9 @@ import org.springframework.test.context.junit4.SpringRunner; import org.springframework.validation.BindException; import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.View; @@ -263,7 +263,7 @@ public String bind() throws Exception { throw error; } - @RequestMapping(path = "/bodyValidation", method = RequestMethod.POST, produces = "application/json") + @PostMapping(path = "/bodyValidation", produces = "application/json") public String bodyValidation(@Valid @RequestBody DummyBody body) { return body.content; } diff --git a/spring-boot-deployment-tests/spring-boot-deployment-test-glassfish/src/main/java/sample/SampleController.java b/spring-boot-deployment-tests/spring-boot-deployment-test-glassfish/src/main/java/sample/SampleController.java index cef966424d62..a02b6ee03479 100644 --- a/spring-boot-deployment-tests/spring-boot-deployment-test-glassfish/src/main/java/sample/SampleController.java +++ b/spring-boot-deployment-tests/spring-boot-deployment-test-glassfish/src/main/java/sample/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,13 +16,13 @@ package sample; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class SampleController { - @RequestMapping("/") + @GetMapping("/") public String hello() { return "Hello World"; } diff --git a/spring-boot-deployment-tests/spring-boot-deployment-test-tomcat/src/main/java/sample/SampleController.java b/spring-boot-deployment-tests/spring-boot-deployment-test-tomcat/src/main/java/sample/SampleController.java index e671d503b33b..bdee6478b12f 100644 --- a/spring-boot-deployment-tests/spring-boot-deployment-test-tomcat/src/main/java/sample/SampleController.java +++ b/spring-boot-deployment-tests/spring-boot-deployment-test-tomcat/src/main/java/sample/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-deployment-tests/spring-boot-deployment-test-tomee/src/main/java/sample/SampleController.java b/spring-boot-deployment-tests/spring-boot-deployment-test-tomee/src/main/java/sample/SampleController.java index e671d503b33b..a02b6ee03479 100644 --- a/spring-boot-deployment-tests/spring-boot-deployment-test-tomee/src/main/java/sample/SampleController.java +++ b/spring-boot-deployment-tests/spring-boot-deployment-test-tomee/src/main/java/sample/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,13 +16,13 @@ package sample; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class SampleController { - @RequestMapping("/") + @GetMapping("/") public String hello() { return "Hello World"; } diff --git a/spring-boot-deployment-tests/spring-boot-deployment-test-wildfly/src/main/java/sample/SampleController.java b/spring-boot-deployment-tests/spring-boot-deployment-test-wildfly/src/main/java/sample/SampleController.java index e671d503b33b..a02b6ee03479 100644 --- a/spring-boot-deployment-tests/spring-boot-deployment-test-wildfly/src/main/java/sample/SampleController.java +++ b/spring-boot-deployment-tests/spring-boot-deployment-test-wildfly/src/main/java/sample/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,13 +16,13 @@ package sample; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class SampleController { - @RequestMapping("/") + @GetMapping("/") public String hello() { return "Hello World"; } diff --git a/spring-boot-samples/spring-boot-sample-actuator-log4j2/src/main/java/sample/actuator/log4j2/SampleController.java b/spring-boot-samples/spring-boot-sample-actuator-log4j2/src/main/java/sample/actuator/log4j2/SampleController.java index 4cee532cc4f3..53a87ac45f34 100644 --- a/spring-boot-samples/spring-boot-sample-actuator-log4j2/src/main/java/sample/actuator/log4j2/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-actuator-log4j2/src/main/java/sample/actuator/log4j2/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @@ -30,7 +31,7 @@ public class SampleController { @Autowired private HelloWorldService helloWorldService; - @RequestMapping("/") + @GetMapping("/") @ResponseBody public Map helloWorld() { return Collections.singletonMap("message", diff --git a/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/java/sample/actuator/ui/SampleActuatorUiApplication.java b/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/java/sample/actuator/ui/SampleActuatorUiApplication.java index 4f5b2b0fcfa2..03b559ab7893 100644 --- a/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/java/sample/actuator/ui/SampleActuatorUiApplication.java +++ b/spring-boot-samples/spring-boot-sample-actuator-ui/src/main/java/sample/actuator/ui/SampleActuatorUiApplication.java @@ -24,13 +24,14 @@ import org.springframework.boot.autoconfigure.security.SecurityProperties; import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @SpringBootApplication @Controller public class SampleActuatorUiApplication { - @RequestMapping("/") + @GetMapping("/") public String home(Map model) { model.put("message", "Hello World"); model.put("title", "Hello Home"); diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/SampleController.java b/spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/SampleController.java index 5b100028cb14..24d28a680176 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,8 +27,9 @@ import org.springframework.context.annotation.Description; import org.springframework.stereotype.Controller; import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -38,14 +39,14 @@ public class SampleController { @Autowired private HelloWorldService helloWorldService; - @RequestMapping(value = "/", method = RequestMethod.GET) + @GetMapping("/") @ResponseBody public Map hello() { return Collections.singletonMap("message", this.helloWorldService.getHelloMessage()); } - @RequestMapping(value = "/", method = RequestMethod.POST) + @PostMapping("/") @ResponseBody public Map olleh(@Validated Message message) { Map model = new LinkedHashMap(); diff --git a/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/web/SampleController.java b/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/web/SampleController.java index 38ba050f8d06..a7fd42aee167 100644 --- a/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/web/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/web/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -30,7 +30,7 @@ public class SampleController { @Autowired private CityService cityService; - @RequestMapping("/") + @GetMapping("/") @ResponseBody @Transactional(readOnly = true) public String helloWorld() { diff --git a/spring-boot-samples/spring-boot-sample-devtools/src/main/java/sample/devtools/MyController.java b/spring-boot-samples/spring-boot-sample-devtools/src/main/java/sample/devtools/MyController.java index 91fa83bda15e..b49d679f517c 100644 --- a/spring-boot-samples/spring-boot-sample-devtools/src/main/java/sample/devtools/MyController.java +++ b/spring-boot-samples/spring-boot-sample-devtools/src/main/java/sample/devtools/MyController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,13 +22,13 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.servlet.ModelAndView; @Controller public class MyController { - @RequestMapping("/") + @GetMapping("/") public ModelAndView get(HttpSession session) { Object sessionVar = session.getAttribute("var"); if (sessionVar == null) { diff --git a/spring-boot-samples/spring-boot-sample-hateoas/src/main/java/sample/hateoas/web/CustomerController.java b/spring-boot-samples/spring-boot-sample-hateoas/src/main/java/sample/hateoas/web/CustomerController.java index 6ebd9a829ca3..87c9bfdc6bfb 100644 --- a/spring-boot-samples/spring-boot-sample-hateoas/src/main/java/sample/hateoas/web/CustomerController.java +++ b/spring-boot-samples/spring-boot-sample-hateoas/src/main/java/sample/hateoas/web/CustomerController.java @@ -28,9 +28,9 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; @Controller @RequestMapping("/customers") @@ -46,7 +46,7 @@ public CustomerController(CustomerRepository repository, EntityLinks entityLinks this.entityLinks = entityLinks; } - @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) HttpEntity> showCustomers() { Resources resources = new Resources( this.repository.findAll()); @@ -54,7 +54,7 @@ HttpEntity> showCustomers() { return new ResponseEntity>(resources, HttpStatus.OK); } - @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE) HttpEntity> showCustomer(@PathVariable Long id) { Resource resource = new Resource(this.repository.findOne(id)); resource.add(this.entityLinks.linkToSingleResource(Customer.class, id)); diff --git a/spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/web/SampleController.java b/spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/web/SampleController.java index 6caf593329d0..190f0309e841 100644 --- a/spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/web/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/web/SampleController.java @@ -21,7 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -30,7 +30,7 @@ public class SampleController { @Autowired private CityService cityService; - @RequestMapping("/") + @GetMapping("/") @ResponseBody @Transactional(readOnly = true) public String helloWorld() { diff --git a/spring-boot-samples/spring-boot-sample-jetty-ssl/src/main/java/sample/jetty/ssl/web/SampleController.java b/spring-boot-samples/spring-boot-sample-jetty-ssl/src/main/java/sample/jetty/ssl/web/SampleController.java index 5c1856d2f7c9..24ff9c43a3e0 100644 --- a/spring-boot-samples/spring-boot-sample-jetty-ssl/src/main/java/sample/jetty/ssl/web/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-jetty-ssl/src/main/java/sample/jetty/ssl/web/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -29,7 +29,7 @@ public class SampleController { @Autowired private HelloWorldService helloWorldService; - @RequestMapping("/") + @GetMapping("/") @ResponseBody public String helloWorld() { return this.helloWorldService.getHelloMessage(); diff --git a/spring-boot-samples/spring-boot-sample-jetty/src/main/java/sample/jetty/web/SampleController.java b/spring-boot-samples/spring-boot-sample-jetty/src/main/java/sample/jetty/web/SampleController.java index 748e0ea88e69..542d2ab0a625 100644 --- a/spring-boot-samples/spring-boot-sample-jetty/src/main/java/sample/jetty/web/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-jetty/src/main/java/sample/jetty/web/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -29,7 +29,7 @@ public class SampleController { @Autowired private HelloWorldService helloWorldService; - @RequestMapping("/") + @GetMapping("/") @ResponseBody public String helloWorld() { return this.helloWorldService.getHelloMessage(); diff --git a/spring-boot-samples/spring-boot-sample-jetty8-ssl/src/main/java/sample/jetty8/ssl/web/SampleController.java b/spring-boot-samples/spring-boot-sample-jetty8-ssl/src/main/java/sample/jetty8/ssl/web/SampleController.java index 919749c1ebae..56bdcefc8ebd 100644 --- a/spring-boot-samples/spring-boot-sample-jetty8-ssl/src/main/java/sample/jetty8/ssl/web/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-jetty8-ssl/src/main/java/sample/jetty8/ssl/web/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -29,7 +29,7 @@ public class SampleController { @Autowired private HelloWorldService helloWorldService; - @RequestMapping("/") + @GetMapping("/") @ResponseBody public String helloWorld() { return this.helloWorldService.getHelloMessage(); diff --git a/spring-boot-samples/spring-boot-sample-jetty8/src/main/java/sample/jetty8/web/SampleController.java b/spring-boot-samples/spring-boot-sample-jetty8/src/main/java/sample/jetty8/web/SampleController.java index 60bcb8aa6ed6..5d4edaf3c654 100644 --- a/spring-boot-samples/spring-boot-sample-jetty8/src/main/java/sample/jetty8/web/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-jetty8/src/main/java/sample/jetty8/web/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -29,7 +29,7 @@ public class SampleController { @Autowired private HelloWorldService helloWorldService; - @RequestMapping("/") + @GetMapping("/") @ResponseBody public String helloWorld() { return this.helloWorldService.getHelloMessage(); diff --git a/spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/web/SampleController.java b/spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/web/SampleController.java index 205fac84d1a5..3368dd849bef 100644 --- a/spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/web/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/web/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -29,7 +29,7 @@ public class SampleController { @Autowired private HelloWorldService helloWorldService; - @RequestMapping("/") + @GetMapping("/") @ResponseBody public String helloWorld() { return this.helloWorldService.getHelloMessage(); diff --git a/spring-boot-samples/spring-boot-sample-jpa/src/main/java/sample/jpa/web/IndexController.java b/spring-boot-samples/spring-boot-sample-jpa/src/main/java/sample/jpa/web/IndexController.java index 356e916253fc..0e6b8fba6cda 100644 --- a/spring-boot-samples/spring-boot-sample-jpa/src/main/java/sample/jpa/web/IndexController.java +++ b/spring-boot-samples/spring-boot-sample-jpa/src/main/java/sample/jpa/web/IndexController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.servlet.ModelAndView; @Controller @@ -33,7 +33,7 @@ public class IndexController { @Autowired private NoteRepository noteRepository; - @RequestMapping("/") + @GetMapping("/") @Transactional(readOnly = true) public ModelAndView index() { List notes = this.noteRepository.findAll(); diff --git a/spring-boot-samples/spring-boot-sample-jta-jndi/src/main/java/sample/jndi/WebController.java b/spring-boot-samples/spring-boot-sample-jta-jndi/src/main/java/sample/jndi/WebController.java index 498f00256d19..a9c84b439188 100644 --- a/spring-boot-samples/spring-boot-sample-jta-jndi/src/main/java/sample/jndi/WebController.java +++ b/spring-boot-samples/spring-boot-sample-jta-jndi/src/main/java/sample/jndi/WebController.java @@ -16,7 +16,7 @@ package sample.jndi; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController @@ -31,7 +31,7 @@ public WebController(AccountService service, AccountRepository repository) { this.repository = repository; } - @RequestMapping("/") + @GetMapping("/") public String hello() { System.out.println("Count is " + this.repository.count()); this.service.createAccountAndNotify("josh"); diff --git a/spring-boot-samples/spring-boot-sample-metrics-dropwizard/src/main/java/sample/metrics/dropwizard/SampleController.java b/spring-boot-samples/spring-boot-sample-metrics-dropwizard/src/main/java/sample/metrics/dropwizard/SampleController.java index b3ff43fb94e6..749b794007e7 100644 --- a/spring-boot-samples/spring-boot-sample-metrics-dropwizard/src/main/java/sample/metrics/dropwizard/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-metrics-dropwizard/src/main/java/sample/metrics/dropwizard/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,8 +25,7 @@ import org.springframework.boot.actuate.metrics.GaugeService; import org.springframework.context.annotation.Description; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -39,7 +38,7 @@ public class SampleController { @Autowired private GaugeService gauges; - @RequestMapping(value = "/", method = RequestMethod.GET) + @GetMapping("/") @ResponseBody public Map hello() { this.gauges.submit("timer.test.value", Math.random() * 1000 + 1000); diff --git a/spring-boot-samples/spring-boot-sample-metrics-opentsdb/src/main/java/sample/metrics/opentsdb/SampleController.java b/spring-boot-samples/spring-boot-sample-metrics-opentsdb/src/main/java/sample/metrics/opentsdb/SampleController.java index 67ab02b5632d..5101d122a3a3 100644 --- a/spring-boot-samples/spring-boot-sample-metrics-opentsdb/src/main/java/sample/metrics/opentsdb/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-metrics-opentsdb/src/main/java/sample/metrics/opentsdb/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Description; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -35,7 +34,7 @@ public class SampleController { @Autowired private HelloWorldService helloWorldService; - @RequestMapping(value = "/", method = RequestMethod.GET) + @GetMapping("/") @ResponseBody public Map hello() { return Collections.singletonMap("message", diff --git a/spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/SampleController.java b/spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/SampleController.java index 27a44909151e..b325a31cba74 100644 --- a/spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Description; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -35,7 +34,7 @@ public class SampleController { @Autowired private HelloWorldService helloWorldService; - @RequestMapping(value = "/", method = RequestMethod.GET) + @GetMapping("/") @ResponseBody public Map hello() { return Collections.singletonMap("message", diff --git a/spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/SampleSecureOAuth2Application.java b/spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/SampleSecureOAuth2Application.java index c75acae8242e..c894a091437f 100644 --- a/spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/SampleSecureOAuth2Application.java +++ b/spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/SampleSecureOAuth2Application.java @@ -22,7 +22,7 @@ import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer; import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; /** @@ -99,7 +99,7 @@ @RestController public class SampleSecureOAuth2Application { - @RequestMapping("/user") + @GetMapping("/user") public Principal user(Principal user) { return user; } diff --git a/spring-boot-samples/spring-boot-sample-session-redis/src/main/java/sample/session/redis/HelloRestController.java b/spring-boot-samples/spring-boot-sample-session-redis/src/main/java/sample/session/redis/HelloRestController.java index 9ff6560b9e96..437ce436acdc 100644 --- a/spring-boot-samples/spring-boot-sample-session-redis/src/main/java/sample/session/redis/HelloRestController.java +++ b/spring-boot-samples/spring-boot-sample-session-redis/src/main/java/sample/session/redis/HelloRestController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,13 +20,13 @@ import javax.servlet.http.HttpSession; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloRestController { - @RequestMapping("/") + @GetMapping("/") String uid(HttpSession session) { UUID uid = (UUID) session.getAttribute("uid"); if (uid == null) { diff --git a/spring-boot-samples/spring-boot-sample-testng/src/main/java/sample/testng/web/SampleController.java b/spring-boot-samples/spring-boot-sample-testng/src/main/java/sample/testng/web/SampleController.java index 2b0a9a190a7d..ae5c61a0adbb 100644 --- a/spring-boot-samples/spring-boot-sample-testng/src/main/java/sample/testng/web/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-testng/src/main/java/sample/testng/web/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -29,7 +29,7 @@ public class SampleController { @Autowired private HelloWorldService helloWorldService; - @RequestMapping("/") + @GetMapping("/") @ResponseBody public String helloWorld() { return this.helloWorldService.getHelloMessage(); diff --git a/spring-boot-samples/spring-boot-sample-tomcat-jsp/src/main/java/sample/tomcat/jsp/WelcomeController.java b/spring-boot-samples/spring-boot-sample-tomcat-jsp/src/main/java/sample/tomcat/jsp/WelcomeController.java index 1e17d9f07f5f..8a56d9b497e0 100644 --- a/spring-boot-samples/spring-boot-sample-tomcat-jsp/src/main/java/sample/tomcat/jsp/WelcomeController.java +++ b/spring-boot-samples/spring-boot-sample-tomcat-jsp/src/main/java/sample/tomcat/jsp/WelcomeController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; @@ -33,7 +34,7 @@ public class WelcomeController { @Value("${application.message:Hello World}") private String message = "Hello World"; - @RequestMapping("/") + @GetMapping("/") public String welcome(Map model) { model.put("time", new Date()); model.put("message", this.message); diff --git a/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors/src/main/java/sample/tomcat/multiconnector/web/SampleController.java b/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors/src/main/java/sample/tomcat/multiconnector/web/SampleController.java index 01b4b4fcd4b9..bb258af235f3 100644 --- a/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors/src/main/java/sample/tomcat/multiconnector/web/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-tomcat-multi-connectors/src/main/java/sample/tomcat/multiconnector/web/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,13 +16,13 @@ package sample.tomcat.multiconnector.web; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class SampleController { - @RequestMapping("/hello") + @GetMapping("/hello") public String helloWorld() { return "hello"; } diff --git a/spring-boot-samples/spring-boot-sample-tomcat-ssl/src/main/java/sample/tomcat/ssl/web/SampleController.java b/spring-boot-samples/spring-boot-sample-tomcat-ssl/src/main/java/sample/tomcat/ssl/web/SampleController.java index 5840fa4e7767..7ca0d5ed01c7 100644 --- a/spring-boot-samples/spring-boot-sample-tomcat-ssl/src/main/java/sample/tomcat/ssl/web/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-tomcat-ssl/src/main/java/sample/tomcat/ssl/web/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,13 +17,13 @@ package sample.tomcat.ssl.web; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller public class SampleController { - @RequestMapping("/") + @GetMapping("/") @ResponseBody public String helloWorld() { return "Hello, world"; diff --git a/spring-boot-samples/spring-boot-sample-tomcat/src/main/java/sample/tomcat/web/SampleController.java b/spring-boot-samples/spring-boot-sample-tomcat/src/main/java/sample/tomcat/web/SampleController.java index 3782f2e1ddbc..2e8e1bd6c02b 100644 --- a/spring-boot-samples/spring-boot-sample-tomcat/src/main/java/sample/tomcat/web/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-tomcat/src/main/java/sample/tomcat/web/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -29,7 +29,7 @@ public class SampleController { @Autowired private HelloWorldService helloWorldService; - @RequestMapping("/") + @GetMapping("/") @ResponseBody public String helloWorld() { return this.helloWorldService.getHelloMessage(); diff --git a/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/java/sample/tomcat7/jsp/WelcomeController.java b/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/java/sample/tomcat7/jsp/WelcomeController.java index a87d336be4e3..7f32d435566f 100644 --- a/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/java/sample/tomcat7/jsp/WelcomeController.java +++ b/spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/java/sample/tomcat7/jsp/WelcomeController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; @Controller public class WelcomeController { @@ -29,7 +29,7 @@ public class WelcomeController { @Value("${application.message:Hello World}") private String message = "Hello World"; - @RequestMapping("/") + @GetMapping("/") public String welcome(Map model) { model.put("time", new Date()); model.put("message", this.message); diff --git a/spring-boot-samples/spring-boot-sample-undertow-ssl/src/main/java/sample/undertow/ssl/web/SampleController.java b/spring-boot-samples/spring-boot-sample-undertow-ssl/src/main/java/sample/undertow/ssl/web/SampleController.java index 96f8d830d472..94252e7f9a45 100644 --- a/spring-boot-samples/spring-boot-sample-undertow-ssl/src/main/java/sample/undertow/ssl/web/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-undertow-ssl/src/main/java/sample/undertow/ssl/web/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller @@ -29,7 +29,7 @@ public class SampleController { @Autowired private HelloWorldService helloWorldService; - @RequestMapping("/") + @GetMapping("/") @ResponseBody public String helloWorld() { return this.helloWorldService.getHelloMessage(); diff --git a/spring-boot-samples/spring-boot-sample-undertow/src/main/java/sample/undertow/web/SampleController.java b/spring-boot-samples/spring-boot-sample-undertow/src/main/java/sample/undertow/web/SampleController.java index 418e77dc4ce9..82e227b0a162 100644 --- a/spring-boot-samples/spring-boot-sample-undertow/src/main/java/sample/undertow/web/SampleController.java +++ b/spring-boot-samples/spring-boot-sample-undertow/src/main/java/sample/undertow/web/SampleController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import sample.undertow.service.HelloWorldService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController @@ -30,12 +30,12 @@ public class SampleController { @Autowired private HelloWorldService helloWorldService; - @RequestMapping("/") + @GetMapping("/") public String helloWorld() { return this.helloWorldService.getHelloMessage(); } - @RequestMapping("/async") + @GetMapping("/async") public Callable helloWorldAsync() { return new Callable() { diff --git a/spring-boot-samples/spring-boot-sample-war/src/main/java/sample/war/MyController.java b/spring-boot-samples/spring-boot-sample-war/src/main/java/sample/war/MyController.java index fc4732ca35b6..06f6f0463b19 100644 --- a/spring-boot-samples/spring-boot-sample-war/src/main/java/sample/war/MyController.java +++ b/spring-boot-samples/spring-boot-sample-war/src/main/java/sample/war/MyController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,13 +16,13 @@ package sample.war; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class MyController { - @RequestMapping("/") + @GetMapping("/") public String hello() { return "Hello World!"; } diff --git a/spring-boot-samples/spring-boot-sample-web-freemarker/src/main/java/sample/freemarker/WelcomeController.java b/spring-boot-samples/spring-boot-sample-web-freemarker/src/main/java/sample/freemarker/WelcomeController.java index 8a97d3b81d26..03ce05a4651b 100644 --- a/spring-boot-samples/spring-boot-sample-web-freemarker/src/main/java/sample/freemarker/WelcomeController.java +++ b/spring-boot-samples/spring-boot-sample-web-freemarker/src/main/java/sample/freemarker/WelcomeController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; @Controller public class WelcomeController { @@ -29,7 +29,7 @@ public class WelcomeController { @Value("${application.message:Hello World}") private String message = "Hello World"; - @RequestMapping("/") + @GetMapping("/") public String welcome(Map model) { model.put("time", new Date()); model.put("message", this.message); diff --git a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/groovytemplates/mvc/MessageController.java b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/groovytemplates/mvc/MessageController.java index b26b344d84d4..89bb29097054 100644 --- a/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/groovytemplates/mvc/MessageController.java +++ b/spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/groovytemplates/mvc/MessageController.java @@ -28,10 +28,11 @@ import org.springframework.validation.BindingResult; import org.springframework.validation.FieldError; import org.springframework.validation.ObjectError; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.support.RedirectAttributes; @@ -45,23 +46,23 @@ public MessageController(MessageRepository messageRepository) { this.messageRepository = messageRepository; } - @RequestMapping + @GetMapping public ModelAndView list() { Iterable messages = this.messageRepository.findAll(); return new ModelAndView("messages/list", "messages", messages); } - @RequestMapping("{id}") + @GetMapping("{id}") public ModelAndView view(@PathVariable("id") Message message) { return new ModelAndView("messages/view", "message", message); } - @RequestMapping(params = "form", method = RequestMethod.GET) + @GetMapping(params = "form") public String createForm(@ModelAttribute Message message) { return "messages/form"; } - @RequestMapping(method = RequestMethod.POST) + @PostMapping public ModelAndView create(@Valid Message message, BindingResult result, RedirectAttributes redirect) { if (result.hasErrors()) { diff --git a/spring-boot-samples/spring-boot-sample-web-jsp/src/main/java/sample/jsp/WelcomeController.java b/spring-boot-samples/spring-boot-sample-web-jsp/src/main/java/sample/jsp/WelcomeController.java index 646c00c3739c..3b879b142a4d 100644 --- a/spring-boot-samples/spring-boot-sample-web-jsp/src/main/java/sample/jsp/WelcomeController.java +++ b/spring-boot-samples/spring-boot-sample-web-jsp/src/main/java/sample/jsp/WelcomeController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @Controller @@ -29,7 +30,7 @@ public class WelcomeController { @Value("${application.message:Hello World}") private String message = "Hello World"; - @RequestMapping("/") + @GetMapping("/") public String welcome(Map model) { model.put("time", new Date()); model.put("message", this.message); diff --git a/spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/security/method/SampleMethodSecurityApplication.java b/spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/security/method/SampleMethodSecurityApplication.java index a31a041af88c..315b21197741 100644 --- a/spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/security/method/SampleMethodSecurityApplication.java +++ b/spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/security/method/SampleMethodSecurityApplication.java @@ -34,7 +34,7 @@ import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.web.util.matcher.AntPathRequestMatcher; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @@ -45,7 +45,7 @@ public class SampleMethodSecurityApplication extends WebMvcConfigurerAdapter { @Controller protected static class HomeController { - @RequestMapping("/") + @GetMapping("/") @Secured("ROLE_ADMIN") public String home(Map model) { model.put("message", "Hello World"); diff --git a/spring-boot-samples/spring-boot-sample-web-mustache/src/main/java/sample/mustache/WelcomeController.java b/spring-boot-samples/spring-boot-sample-web-mustache/src/main/java/sample/mustache/WelcomeController.java index ea5baf769e73..8f2e4f45d4e4 100644 --- a/spring-boot-samples/spring-boot-sample-web-mustache/src/main/java/sample/mustache/WelcomeController.java +++ b/spring-boot-samples/spring-boot-sample-web-mustache/src/main/java/sample/mustache/WelcomeController.java @@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseStatus; @@ -31,7 +32,7 @@ public class WelcomeController { @Value("${application.message:Hello World}") private String message = "Hello World"; - @RequestMapping("/") + @GetMapping("/") public String welcome(Map model) { model.put("time", new Date()); model.put("message", this.message); diff --git a/spring-boot-samples/spring-boot-sample-web-secure-custom/src/main/java/sample/web/secure/custom/SampleWebSecureCustomApplication.java b/spring-boot-samples/spring-boot-sample-web-secure-custom/src/main/java/sample/web/secure/custom/SampleWebSecureCustomApplication.java index d05c328a76d3..751277793cc3 100644 --- a/spring-boot-samples/spring-boot-sample-web-secure-custom/src/main/java/sample/web/secure/custom/SampleWebSecureCustomApplication.java +++ b/spring-boot-samples/spring-boot-sample-web-secure-custom/src/main/java/sample/web/secure/custom/SampleWebSecureCustomApplication.java @@ -28,6 +28,7 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @@ -36,7 +37,7 @@ @Controller public class SampleWebSecureCustomApplication extends WebMvcConfigurerAdapter { - @RequestMapping("/") + @GetMapping("/") public String home(Map model) { model.put("message", "Hello World"); model.put("title", "Hello Home"); diff --git a/spring-boot-samples/spring-boot-sample-web-secure-jdbc/src/main/java/sample/web/secure/jdbc/SampleWebSecureCustomApplication.java b/spring-boot-samples/spring-boot-sample-web-secure-jdbc/src/main/java/sample/web/secure/jdbc/SampleWebSecureCustomApplication.java index abdcb2bb51f0..0ded1fd25bd8 100644 --- a/spring-boot-samples/spring-boot-sample-web-secure-jdbc/src/main/java/sample/web/secure/jdbc/SampleWebSecureCustomApplication.java +++ b/spring-boot-samples/spring-boot-sample-web-secure-jdbc/src/main/java/sample/web/secure/jdbc/SampleWebSecureCustomApplication.java @@ -31,6 +31,7 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @@ -39,7 +40,7 @@ @Controller public class SampleWebSecureCustomApplication extends WebMvcConfigurerAdapter { - @RequestMapping("/") + @GetMapping("/") public String home(Map model) { model.put("message", "Hello World"); model.put("title", "Hello Home"); diff --git a/spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/web/secure/SampleWebSecureApplication.java b/spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/web/secure/SampleWebSecureApplication.java index 12b2b47f1026..09c3dbc74c5f 100644 --- a/spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/web/secure/SampleWebSecureApplication.java +++ b/spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/web/secure/SampleWebSecureApplication.java @@ -28,6 +28,7 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @@ -36,7 +37,7 @@ @Controller public class SampleWebSecureApplication extends WebMvcConfigurerAdapter { - @RequestMapping("/") + @GetMapping("/") public String home(Map model) { model.put("message", "Hello World"); model.put("title", "Hello Home"); diff --git a/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/mvc/MessageController.java b/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/mvc/MessageController.java index 710b0a716853..4f144fd28885 100755 --- a/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/mvc/MessageController.java +++ b/spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/mvc/MessageController.java @@ -23,10 +23,11 @@ import org.springframework.stereotype.Controller; import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.support.RedirectAttributes; @@ -44,23 +45,23 @@ public MessageController(MessageRepository messageRepository) { this.messageRepository = messageRepository; } - @RequestMapping + @GetMapping public ModelAndView list() { Iterable messages = this.messageRepository.findAll(); return new ModelAndView("messages/list", "messages", messages); } - @RequestMapping("{id}") + @GetMapping("{id}") public ModelAndView view(@PathVariable("id") Message message) { return new ModelAndView("messages/view", "message", message); } - @RequestMapping(params = "form", method = RequestMethod.GET) + @GetMapping(params = "form") public String createForm(@ModelAttribute Message message) { return "messages/form"; } - @RequestMapping(method = RequestMethod.POST) + @PostMapping public ModelAndView create(@Valid Message message, BindingResult result, RedirectAttributes redirect) { if (result.hasErrors()) { @@ -76,14 +77,14 @@ public String foo() { throw new RuntimeException("Expected exception in controller"); } - @RequestMapping(value = "delete/{id}") + @GetMapping(value = "delete/{id}") public ModelAndView delete(@PathVariable("id") Long id) { this.messageRepository.deleteMessage(id); Iterable messages = this.messageRepository.findAll(); return new ModelAndView("messages/list", "messages", messages); } - @RequestMapping(value = "modify/{id}", method = RequestMethod.GET) + @GetMapping(value = "modify/{id}") public ModelAndView modifyForm(@PathVariable("id") Message message) { return new ModelAndView("messages/form", "message", message); } diff --git a/spring-boot-samples/spring-boot-sample-web-velocity/src/main/java/sample/web/velocity/WelcomeController.java b/spring-boot-samples/spring-boot-sample-web-velocity/src/main/java/sample/web/velocity/WelcomeController.java index 140424584df7..417cccef3acc 100644 --- a/spring-boot-samples/spring-boot-sample-web-velocity/src/main/java/sample/web/velocity/WelcomeController.java +++ b/spring-boot-samples/spring-boot-sample-web-velocity/src/main/java/sample/web/velocity/WelcomeController.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; @Controller public class WelcomeController { @@ -29,7 +29,7 @@ public class WelcomeController { @Value("${application.message:Hello World}") private String message = "Hello World"; - @RequestMapping("/") + @GetMapping("/") public String welcome(Map model) { model.put("time", new Date()); model.put("message", this.message);