Browse Source

Make use of new GetMapping and PostMapping annotations

Closes gh-5277
pull/5912/head
Andy Wilkinson 10 years ago
parent
commit
3348ed5bb3
  1. 5
      spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EndpointMvcAdapter.java
  2. 5
      spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpoint.java
  3. 5
      spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/MetricsMvcEndpoint.java
  4. 5
      spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpoint.java
  5. 5
      spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EndpointHandlerMappingTests.java
  6. 11
      spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java
  7. 4
      spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/BasicErrorControllerIntegrationTests.java
  8. 6
      spring-boot-deployment-tests/spring-boot-deployment-test-glassfish/src/main/java/sample/SampleController.java
  9. 2
      spring-boot-deployment-tests/spring-boot-deployment-test-tomcat/src/main/java/sample/SampleController.java
  10. 6
      spring-boot-deployment-tests/spring-boot-deployment-test-tomee/src/main/java/sample/SampleController.java
  11. 6
      spring-boot-deployment-tests/spring-boot-deployment-test-wildfly/src/main/java/sample/SampleController.java
  12. 5
      spring-boot-samples/spring-boot-sample-actuator-log4j2/src/main/java/sample/actuator/log4j2/SampleController.java
  13. 3
      spring-boot-samples/spring-boot-sample-actuator-ui/src/main/java/sample/actuator/ui/SampleActuatorUiApplication.java
  14. 9
      spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/SampleController.java
  15. 6
      spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/web/SampleController.java
  16. 6
      spring-boot-samples/spring-boot-sample-devtools/src/main/java/sample/devtools/MyController.java
  17. 6
      spring-boot-samples/spring-boot-sample-hateoas/src/main/java/sample/hateoas/web/CustomerController.java
  18. 4
      spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/web/SampleController.java
  19. 6
      spring-boot-samples/spring-boot-sample-jetty-ssl/src/main/java/sample/jetty/ssl/web/SampleController.java
  20. 6
      spring-boot-samples/spring-boot-sample-jetty/src/main/java/sample/jetty/web/SampleController.java
  21. 6
      spring-boot-samples/spring-boot-sample-jetty8-ssl/src/main/java/sample/jetty8/ssl/web/SampleController.java
  22. 6
      spring-boot-samples/spring-boot-sample-jetty8/src/main/java/sample/jetty8/web/SampleController.java
  23. 6
      spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/web/SampleController.java
  24. 6
      spring-boot-samples/spring-boot-sample-jpa/src/main/java/sample/jpa/web/IndexController.java
  25. 4
      spring-boot-samples/spring-boot-sample-jta-jndi/src/main/java/sample/jndi/WebController.java
  26. 7
      spring-boot-samples/spring-boot-sample-metrics-dropwizard/src/main/java/sample/metrics/dropwizard/SampleController.java
  27. 7
      spring-boot-samples/spring-boot-sample-metrics-opentsdb/src/main/java/sample/metrics/opentsdb/SampleController.java
  28. 7
      spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/SampleController.java
  29. 4
      spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/SampleSecureOAuth2Application.java
  30. 6
      spring-boot-samples/spring-boot-sample-session-redis/src/main/java/sample/session/redis/HelloRestController.java
  31. 6
      spring-boot-samples/spring-boot-sample-testng/src/main/java/sample/testng/web/SampleController.java
  32. 5
      spring-boot-samples/spring-boot-sample-tomcat-jsp/src/main/java/sample/tomcat/jsp/WelcomeController.java
  33. 6
      spring-boot-samples/spring-boot-sample-tomcat-multi-connectors/src/main/java/sample/tomcat/multiconnector/web/SampleController.java
  34. 6
      spring-boot-samples/spring-boot-sample-tomcat-ssl/src/main/java/sample/tomcat/ssl/web/SampleController.java
  35. 6
      spring-boot-samples/spring-boot-sample-tomcat/src/main/java/sample/tomcat/web/SampleController.java
  36. 6
      spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/java/sample/tomcat7/jsp/WelcomeController.java
  37. 6
      spring-boot-samples/spring-boot-sample-undertow-ssl/src/main/java/sample/undertow/ssl/web/SampleController.java
  38. 8
      spring-boot-samples/spring-boot-sample-undertow/src/main/java/sample/undertow/web/SampleController.java
  39. 6
      spring-boot-samples/spring-boot-sample-war/src/main/java/sample/war/MyController.java
  40. 6
      spring-boot-samples/spring-boot-sample-web-freemarker/src/main/java/sample/freemarker/WelcomeController.java
  41. 11
      spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/groovytemplates/mvc/MessageController.java
  42. 5
      spring-boot-samples/spring-boot-sample-web-jsp/src/main/java/sample/jsp/WelcomeController.java
  43. 4
      spring-boot-samples/spring-boot-sample-web-method-security/src/main/java/sample/security/method/SampleMethodSecurityApplication.java
  44. 3
      spring-boot-samples/spring-boot-sample-web-mustache/src/main/java/sample/mustache/WelcomeController.java
  45. 3
      spring-boot-samples/spring-boot-sample-web-secure-custom/src/main/java/sample/web/secure/custom/SampleWebSecureCustomApplication.java
  46. 3
      spring-boot-samples/spring-boot-sample-web-secure-jdbc/src/main/java/sample/web/secure/jdbc/SampleWebSecureCustomApplication.java
  47. 3
      spring-boot-samples/spring-boot-sample-web-secure/src/main/java/sample/web/secure/SampleWebSecureApplication.java
  48. 15
      spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/mvc/MessageController.java
  49. 6
      spring-boot-samples/spring-boot-sample-web-velocity/src/main/java/sample/web/velocity/WelcomeController.java

5
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EndpointMvcAdapter.java

@ -18,8 +18,7 @@ package org.springframework.boot.actuate.endpoint.mvc; @@ -18,8 +18,7 @@ package org.springframework.boot.actuate.endpoint.mvc;
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 class EndpointMvcAdapter extends AbstractEndpointMvcAdapter<Endpoint<?>> @@ -39,7 +38,7 @@ public class EndpointMvcAdapter extends AbstractEndpointMvcAdapter<Endpoint<?>>
}
@Override
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Object invoke() {
return super.invoke();

5
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpoint.java

@ -26,9 +26,8 @@ import org.springframework.core.env.PropertySource; @@ -26,9 +26,8 @@ import org.springframework.core.env.PropertySource;
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 class EnvironmentMvcEndpoint extends EndpointMvcAdapter @@ -49,7 +48,7 @@ public class EnvironmentMvcEndpoint extends EndpointMvcAdapter
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) {

5
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/MetricsMvcEndpoint.java

@ -22,9 +22,8 @@ import org.springframework.boot.actuate.endpoint.MetricsEndpoint; @@ -22,9 +22,8 @@ import org.springframework.boot.actuate.endpoint.MetricsEndpoint;
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 class MetricsMvcEndpoint extends EndpointMvcAdapter { @@ -45,7 +44,7 @@ public class MetricsMvcEndpoint extends EndpointMvcAdapter {
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) {

5
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/ShutdownMvcEndpoint.java

@ -23,8 +23,7 @@ import org.springframework.boot.actuate.endpoint.ShutdownEndpoint; @@ -23,8 +23,7 @@ import org.springframework.boot.actuate.endpoint.ShutdownEndpoint;
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 class ShutdownMvcEndpoint extends EndpointMvcAdapter { @@ -39,7 +38,7 @@ public class ShutdownMvcEndpoint extends EndpointMvcAdapter {
super(delegate);
}
@RequestMapping(method = RequestMethod.POST)
@PostMapping
@ResponseBody
@Override
public Object invoke() {

5
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EndpointHandlerMappingTests.java

@ -27,8 +27,7 @@ import org.springframework.context.support.StaticApplicationContext; @@ -27,8 +27,7 @@ import org.springframework.context.support.StaticApplicationContext;
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 @@ public class EndpointHandlerMappingTests { @@ -168,7 +167,7 @@ public class EndpointHandlerMappingTests {
}
@Override
@RequestMapping(method = RequestMethod.POST)
@PostMapping
public Object invoke() {
return null;
}

11
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/OAuth2AutoConfigurationTests.java

@ -90,8 +90,8 @@ import org.springframework.security.oauth2.provider.token.store.InMemoryTokenSto @@ -90,8 +90,8 @@ import org.springframework.security.oauth2.provider.token.store.InMemoryTokenSto
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 class OAuth2AutoConfigurationTests { @@ -191,7 +191,8 @@ public class OAuth2AutoConfigurationTests {
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 @@ public class OAuth2AutoConfigurationTests { @@ -465,13 +466,13 @@ public class OAuth2AutoConfigurationTests {
@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";

4
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/BasicErrorControllerIntegrationTests.java

@ -49,9 +49,9 @@ import org.springframework.test.annotation.DirtiesContext; @@ -49,9 +49,9 @@ import org.springframework.test.annotation.DirtiesContext;
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 class BasicErrorControllerIntegrationTests { @@ -263,7 +263,7 @@ public class BasicErrorControllerIntegrationTests {
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;
}

6
spring-boot-deployment-tests/spring-boot-deployment-test-glassfish/src/main/java/sample/SampleController.java

@ -1,5 +1,5 @@ @@ -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 @@ @@ -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";
}

2
spring-boot-deployment-tests/spring-boot-deployment-test-tomcat/src/main/java/sample/SampleController.java

@ -1,5 +1,5 @@ @@ -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.

6
spring-boot-deployment-tests/spring-boot-deployment-test-tomee/src/main/java/sample/SampleController.java

@ -1,5 +1,5 @@ @@ -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 @@ @@ -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";
}

6
spring-boot-deployment-tests/spring-boot-deployment-test-wildfly/src/main/java/sample/SampleController.java

@ -1,5 +1,5 @@ @@ -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 @@ @@ -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";
}

5
spring-boot-samples/spring-boot-sample-actuator-log4j2/src/main/java/sample/actuator/log4j2/SampleController.java

@ -1,5 +1,5 @@ @@ -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 java.util.Map; @@ -21,6 +21,7 @@ import java.util.Map;
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 { @@ -30,7 +31,7 @@ public class SampleController {
@Autowired
private HelloWorldService helloWorldService;
@RequestMapping("/")
@GetMapping("/")
@ResponseBody
public Map<String, String> helloWorld() {
return Collections.singletonMap("message",

3
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.SpringBootApplication; @@ -24,13 +24,14 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
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<String, Object> model) {
model.put("message", "Hello World");
model.put("title", "Hello Home");

9
spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/SampleController.java

@ -1,5 +1,5 @@ @@ -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.beans.factory.annotation.Autowired; @@ -27,8 +27,9 @@ import org.springframework.beans.factory.annotation.Autowired;
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 { @@ -38,14 +39,14 @@ public class SampleController {
@Autowired
private HelloWorldService helloWorldService;
@RequestMapping(value = "/", method = RequestMethod.GET)
@GetMapping("/")
@ResponseBody
public Map<String, String> hello() {
return Collections.singletonMap("message",
this.helloWorldService.getHelloMessage());
}
@RequestMapping(value = "/", method = RequestMethod.POST)
@PostMapping("/")
@ResponseBody
public Map<String, Object> olleh(@Validated Message message) {
Map<String, Object> model = new LinkedHashMap<String, Object>();

6
spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/web/SampleController.java

@ -1,5 +1,5 @@ @@ -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 sample.data.jpa.service.CityService; @@ -21,7 +21,7 @@ import sample.data.jpa.service.CityService;
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 { @@ -30,7 +30,7 @@ public class SampleController {
@Autowired
private CityService cityService;
@RequestMapping("/")
@GetMapping("/")
@ResponseBody
@Transactional(readOnly = true)
public String helloWorld() {

6
spring-boot-samples/spring-boot-sample-devtools/src/main/java/sample/devtools/MyController.java

@ -1,5 +1,5 @@ @@ -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 javax.servlet.http.HttpSession; @@ -22,13 +22,13 @@ import javax.servlet.http.HttpSession;
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) {

6
spring-boot-samples/spring-boot-sample-hateoas/src/main/java/sample/hateoas/web/CustomerController.java

@ -28,9 +28,9 @@ import org.springframework.http.HttpStatus; @@ -28,9 +28,9 @@ import org.springframework.http.HttpStatus;
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 class CustomerController { @@ -46,7 +46,7 @@ public class CustomerController {
this.entityLinks = entityLinks;
}
@RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
HttpEntity<Resources<Customer>> showCustomers() {
Resources<Customer> resources = new Resources<Customer>(
this.repository.findAll());
@ -54,7 +54,7 @@ public class CustomerController { @@ -54,7 +54,7 @@ public class CustomerController {
return new ResponseEntity<Resources<Customer>>(resources, HttpStatus.OK);
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping(path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
HttpEntity<Resource<Customer>> showCustomer(@PathVariable Long id) {
Resource<Customer> resource = new Resource<Customer>(this.repository.findOne(id));
resource.add(this.entityLinks.linkToSingleResource(Customer.class, id));

4
spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/web/SampleController.java

@ -21,7 +21,7 @@ import sample.hibernate4.service.CityService; @@ -21,7 +21,7 @@ import sample.hibernate4.service.CityService;
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 { @@ -30,7 +30,7 @@ public class SampleController {
@Autowired
private CityService cityService;
@RequestMapping("/")
@GetMapping("/")
@ResponseBody
@Transactional(readOnly = true)
public String helloWorld() {

6
spring-boot-samples/spring-boot-sample-jetty-ssl/src/main/java/sample/jetty/ssl/web/SampleController.java

@ -1,5 +1,5 @@ @@ -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 sample.jetty.ssl.service.HelloWorldService; @@ -20,7 +20,7 @@ import sample.jetty.ssl.service.HelloWorldService;
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 { @@ -29,7 +29,7 @@ public class SampleController {
@Autowired
private HelloWorldService helloWorldService;
@RequestMapping("/")
@GetMapping("/")
@ResponseBody
public String helloWorld() {
return this.helloWorldService.getHelloMessage();

6
spring-boot-samples/spring-boot-sample-jetty/src/main/java/sample/jetty/web/SampleController.java

@ -1,5 +1,5 @@ @@ -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 sample.jetty.service.HelloWorldService; @@ -20,7 +20,7 @@ import sample.jetty.service.HelloWorldService;
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 { @@ -29,7 +29,7 @@ public class SampleController {
@Autowired
private HelloWorldService helloWorldService;
@RequestMapping("/")
@GetMapping("/")
@ResponseBody
public String helloWorld() {
return this.helloWorldService.getHelloMessage();

6
spring-boot-samples/spring-boot-sample-jetty8-ssl/src/main/java/sample/jetty8/ssl/web/SampleController.java

@ -1,5 +1,5 @@ @@ -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 sample.jetty8.ssl.service.HelloWorldService; @@ -20,7 +20,7 @@ import sample.jetty8.ssl.service.HelloWorldService;
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 { @@ -29,7 +29,7 @@ public class SampleController {
@Autowired
private HelloWorldService helloWorldService;
@RequestMapping("/")
@GetMapping("/")
@ResponseBody
public String helloWorld() {
return this.helloWorldService.getHelloMessage();

6
spring-boot-samples/spring-boot-sample-jetty8/src/main/java/sample/jetty8/web/SampleController.java

@ -1,5 +1,5 @@ @@ -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 sample.jetty8.service.HelloWorldService; @@ -20,7 +20,7 @@ import sample.jetty8.service.HelloWorldService;
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 { @@ -29,7 +29,7 @@ public class SampleController {
@Autowired
private HelloWorldService helloWorldService;
@RequestMapping("/")
@GetMapping("/")
@ResponseBody
public String helloWorld() {
return this.helloWorldService.getHelloMessage();

6
spring-boot-samples/spring-boot-sample-jetty93/src/main/java/sample/jetty93/web/SampleController.java

@ -1,5 +1,5 @@ @@ -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 sample.jetty93.service.HelloWorldService; @@ -20,7 +20,7 @@ import sample.jetty93.service.HelloWorldService;
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 { @@ -29,7 +29,7 @@ public class SampleController {
@Autowired
private HelloWorldService helloWorldService;
@RequestMapping("/")
@GetMapping("/")
@ResponseBody
public String helloWorld() {
return this.helloWorldService.getHelloMessage();

6
spring-boot-samples/spring-boot-sample-jpa/src/main/java/sample/jpa/web/IndexController.java

@ -1,5 +1,5 @@ @@ -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 sample.jpa.repository.NoteRepository; @@ -24,7 +24,7 @@ import sample.jpa.repository.NoteRepository;
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 { @@ -33,7 +33,7 @@ public class IndexController {
@Autowired
private NoteRepository noteRepository;
@RequestMapping("/")
@GetMapping("/")
@Transactional(readOnly = true)
public ModelAndView index() {
List<Note> notes = this.noteRepository.findAll();

4
spring-boot-samples/spring-boot-sample-jta-jndi/src/main/java/sample/jndi/WebController.java

@ -16,7 +16,7 @@ @@ -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 class WebController { @@ -31,7 +31,7 @@ public class WebController {
this.repository = repository;
}
@RequestMapping("/")
@GetMapping("/")
public String hello() {
System.out.println("Count is " + this.repository.count());
this.service.createAccountAndNotify("josh");

7
spring-boot-samples/spring-boot-sample-metrics-dropwizard/src/main/java/sample/metrics/dropwizard/SampleController.java

@ -1,5 +1,5 @@ @@ -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.beans.factory.annotation.Autowired; @@ -25,8 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
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 { @@ -39,7 +38,7 @@ public class SampleController {
@Autowired
private GaugeService gauges;
@RequestMapping(value = "/", method = RequestMethod.GET)
@GetMapping("/")
@ResponseBody
public Map<String, String> hello() {
this.gauges.submit("timer.test.value", Math.random() * 1000 + 1000);

7
spring-boot-samples/spring-boot-sample-metrics-opentsdb/src/main/java/sample/metrics/opentsdb/SampleController.java

@ -1,5 +1,5 @@ @@ -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.hibernate.validator.constraints.NotBlank; @@ -24,8 +24,7 @@ import org.hibernate.validator.constraints.NotBlank;
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 { @@ -35,7 +34,7 @@ public class SampleController {
@Autowired
private HelloWorldService helloWorldService;
@RequestMapping(value = "/", method = RequestMethod.GET)
@GetMapping("/")
@ResponseBody
public Map<String, String> hello() {
return Collections.singletonMap("message",

7
spring-boot-samples/spring-boot-sample-metrics-redis/src/main/java/sample/metrics/redis/SampleController.java

@ -1,5 +1,5 @@ @@ -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.hibernate.validator.constraints.NotBlank; @@ -24,8 +24,7 @@ import org.hibernate.validator.constraints.NotBlank;
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 { @@ -35,7 +34,7 @@ public class SampleController {
@Autowired
private HelloWorldService helloWorldService;
@RequestMapping(value = "/", method = RequestMethod.GET)
@GetMapping("/")
@ResponseBody
public Map<String, String> hello() {
return Collections.singletonMap("message",

4
spring-boot-samples/spring-boot-sample-secure-oauth2/src/main/java/sample/secure/oauth2/SampleSecureOAuth2Application.java

@ -22,7 +22,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -22,7 +22,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
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 @@ import org.springframework.web.bind.annotation.RestController; @@ -99,7 +99,7 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
public class SampleSecureOAuth2Application {
@RequestMapping("/user")
@GetMapping("/user")
public Principal user(Principal user) {
return user;
}

6
spring-boot-samples/spring-boot-sample-session-redis/src/main/java/sample/session/redis/HelloRestController.java

@ -1,5 +1,5 @@ @@ -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 java.util.UUID; @@ -20,13 +20,13 @@ import java.util.UUID;
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) {

6
spring-boot-samples/spring-boot-sample-testng/src/main/java/sample/testng/web/SampleController.java

@ -1,5 +1,5 @@ @@ -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 sample.testng.service.HelloWorldService; @@ -20,7 +20,7 @@ import sample.testng.service.HelloWorldService;
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 { @@ -29,7 +29,7 @@ public class SampleController {
@Autowired
private HelloWorldService helloWorldService;
@RequestMapping("/")
@GetMapping("/")
@ResponseBody
public String helloWorld() {
return this.helloWorldService.getHelloMessage();

5
spring-boot-samples/spring-boot-sample-tomcat-jsp/src/main/java/sample/tomcat/jsp/WelcomeController.java

@ -1,5 +1,5 @@ @@ -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.beans.factory.annotation.Value; @@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Value;
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 { @@ -33,7 +34,7 @@ public class WelcomeController {
@Value("${application.message:Hello World}")
private String message = "Hello World";
@RequestMapping("/")
@GetMapping("/")
public String welcome(Map<String, Object> model) {
model.put("time", new Date());
model.put("message", this.message);

6
spring-boot-samples/spring-boot-sample-tomcat-multi-connectors/src/main/java/sample/tomcat/multiconnector/web/SampleController.java

@ -1,5 +1,5 @@ @@ -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 @@ @@ -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";
}

6
spring-boot-samples/spring-boot-sample-tomcat-ssl/src/main/java/sample/tomcat/ssl/web/SampleController.java

@ -1,5 +1,5 @@ @@ -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 @@ @@ -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";

6
spring-boot-samples/spring-boot-sample-tomcat/src/main/java/sample/tomcat/web/SampleController.java

@ -1,5 +1,5 @@ @@ -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 sample.tomcat.service.HelloWorldService; @@ -20,7 +20,7 @@ import sample.tomcat.service.HelloWorldService;
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 { @@ -29,7 +29,7 @@ public class SampleController {
@Autowired
private HelloWorldService helloWorldService;
@RequestMapping("/")
@GetMapping("/")
@ResponseBody
public String helloWorld() {
return this.helloWorldService.getHelloMessage();

6
spring-boot-samples/spring-boot-sample-tomcat7-jsp/src/main/java/sample/tomcat7/jsp/WelcomeController.java

@ -1,5 +1,5 @@ @@ -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 java.util.Map; @@ -21,7 +21,7 @@ import java.util.Map;
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 { @@ -29,7 +29,7 @@ public class WelcomeController {
@Value("${application.message:Hello World}")
private String message = "Hello World";
@RequestMapping("/")
@GetMapping("/")
public String welcome(Map<String, Object> model) {
model.put("time", new Date());
model.put("message", this.message);

6
spring-boot-samples/spring-boot-sample-undertow-ssl/src/main/java/sample/undertow/ssl/web/SampleController.java

@ -1,5 +1,5 @@ @@ -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 sample.undertow.ssl.service.HelloWorldService; @@ -20,7 +20,7 @@ import sample.undertow.ssl.service.HelloWorldService;
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 { @@ -29,7 +29,7 @@ public class SampleController {
@Autowired
private HelloWorldService helloWorldService;
@RequestMapping("/")
@GetMapping("/")
@ResponseBody
public String helloWorld() {
return this.helloWorldService.getHelloMessage();

8
spring-boot-samples/spring-boot-sample-undertow/src/main/java/sample/undertow/web/SampleController.java

@ -1,5 +1,5 @@ @@ -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 java.util.concurrent.Callable; @@ -21,7 +21,7 @@ import java.util.concurrent.Callable;
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 { @@ -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<String> helloWorldAsync() {
return new Callable<String>() {

6
spring-boot-samples/spring-boot-sample-war/src/main/java/sample/war/MyController.java

@ -1,5 +1,5 @@ @@ -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 @@ @@ -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!";
}

6
spring-boot-samples/spring-boot-sample-web-freemarker/src/main/java/sample/freemarker/WelcomeController.java

@ -1,5 +1,5 @@ @@ -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 java.util.Map; @@ -21,7 +21,7 @@ import java.util.Map;
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 { @@ -29,7 +29,7 @@ public class WelcomeController {
@Value("${application.message:Hello World}")
private String message = "Hello World";
@RequestMapping("/")
@GetMapping("/")
public String welcome(Map<String, Object> model) {
model.put("time", new Date());
model.put("message", this.message);

11
spring-boot-samples/spring-boot-sample-web-groovy-templates/src/main/java/sample/groovytemplates/mvc/MessageController.java

@ -28,10 +28,11 @@ import org.springframework.stereotype.Controller; @@ -28,10 +28,11 @@ import org.springframework.stereotype.Controller;
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 class MessageController { @@ -45,23 +46,23 @@ public class MessageController {
this.messageRepository = messageRepository;
}
@RequestMapping
@GetMapping
public ModelAndView list() {
Iterable<Message> 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()) {

5
spring-boot-samples/spring-boot-sample-web-jsp/src/main/java/sample/jsp/WelcomeController.java

@ -1,5 +1,5 @@ @@ -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 java.util.Map; @@ -21,6 +21,7 @@ import java.util.Map;
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 { @@ -29,7 +30,7 @@ public class WelcomeController {
@Value("${application.message:Hello World}")
private String message = "Hello World";
@RequestMapping("/")
@GetMapping("/")
public String welcome(Map<String, Object> model) {
model.put("time", new Date());
model.put("message", this.message);

4
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.builders.HttpSecurity; @@ -34,7 +34,7 @@ import org.springframework.security.config.annotation.web.builders.HttpSecurity;
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 { @@ -45,7 +45,7 @@ public class SampleMethodSecurityApplication extends WebMvcConfigurerAdapter {
@Controller
protected static class HomeController {
@RequestMapping("/")
@GetMapping("/")
@Secured("ROLE_ADMIN")
public String home(Map<String, Object> model) {
model.put("message", "Hello World");

3
spring-boot-samples/spring-boot-sample-web-mustache/src/main/java/sample/mustache/WelcomeController.java

@ -22,6 +22,7 @@ import java.util.Map; @@ -22,6 +22,7 @@ import java.util.Map;
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 { @@ -31,7 +32,7 @@ public class WelcomeController {
@Value("${application.message:Hello World}")
private String message = "Hello World";
@RequestMapping("/")
@GetMapping("/")
public String welcome(Map<String, Object> model) {
model.put("time", new Date());
model.put("message", this.message);

3
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.authentication.builders.Au @@ -28,6 +28,7 @@ import org.springframework.security.config.annotation.authentication.builders.Au
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 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter @@ -36,7 +37,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@Controller
public class SampleWebSecureCustomApplication extends WebMvcConfigurerAdapter {
@RequestMapping("/")
@GetMapping("/")
public String home(Map<String, Object> model) {
model.put("message", "Hello World");
model.put("title", "Hello Home");

3
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.authentication.builders.Au @@ -31,6 +31,7 @@ import org.springframework.security.config.annotation.authentication.builders.Au
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 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter @@ -39,7 +40,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@Controller
public class SampleWebSecureCustomApplication extends WebMvcConfigurerAdapter {
@RequestMapping("/")
@GetMapping("/")
public String home(Map<String, Object> model) {
model.put("message", "Hello World");
model.put("title", "Hello Home");

3
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.authentication.builders.Au @@ -28,6 +28,7 @@ import org.springframework.security.config.annotation.authentication.builders.Au
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 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter @@ -36,7 +37,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@Controller
public class SampleWebSecureApplication extends WebMvcConfigurerAdapter {
@RequestMapping("/")
@GetMapping("/")
public String home(Map<String, Object> model) {
model.put("message", "Hello World");
model.put("title", "Hello Home");

15
spring-boot-samples/spring-boot-sample-web-ui/src/main/java/sample/web/ui/mvc/MessageController.java

@ -23,10 +23,11 @@ import sample.web.ui.MessageRepository; @@ -23,10 +23,11 @@ import sample.web.ui.MessageRepository;
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 class MessageController { @@ -44,23 +45,23 @@ public class MessageController {
this.messageRepository = messageRepository;
}
@RequestMapping
@GetMapping
public ModelAndView list() {
Iterable<Message> 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 class MessageController { @@ -76,14 +77,14 @@ public class MessageController {
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<Message> 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);
}

6
spring-boot-samples/spring-boot-sample-web-velocity/src/main/java/sample/web/velocity/WelcomeController.java

@ -1,5 +1,5 @@ @@ -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 java.util.Map; @@ -21,7 +21,7 @@ import java.util.Map;
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 { @@ -29,7 +29,7 @@ public class WelcomeController {
@Value("${application.message:Hello World}")
private String message = "Hello World";
@RequestMapping("/")
@GetMapping("/")
public String welcome(Map<String, Object> model) {
model.put("time", new Date());
model.put("message", this.message);

Loading…
Cancel
Save