diff --git a/spring-cloud-config-monitor/src/main/java/org/springframework/cloud/config/monitor/PropertyPathEndpoint.java b/spring-cloud-config-monitor/src/main/java/org/springframework/cloud/config/monitor/PropertyPathEndpoint.java index f8446eca..e8920b19 100644 --- a/spring-cloud-config-monitor/src/main/java/org/springframework/cloud/config/monitor/PropertyPathEndpoint.java +++ b/spring-cloud-config-monitor/src/main/java/org/springframework/cloud/config/monitor/PropertyPathEndpoint.java @@ -32,10 +32,10 @@ import org.springframework.context.ApplicationEventPublisherAware; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -71,7 +71,7 @@ public class PropertyPathEndpoint implements ApplicationEventPublisherAware { this.applicationEventPublisher = applicationEventPublisher; } - @RequestMapping(method = RequestMethod.POST) + @PostMapping public Set notifyByPath(@RequestHeader HttpHeaders headers, @RequestBody Map request) { PropertyPathNotification notification = this.extractor.extract(headers, request); if (notification != null) { @@ -94,7 +94,7 @@ public class PropertyPathEndpoint implements ApplicationEventPublisherAware { return Collections.emptySet(); } - @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) + @PostMapping(consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) public Set notifyByForm(@RequestHeader HttpHeaders headers, @RequestParam("path") List request) { Map map = new HashMap<>(); String key = "path"; diff --git a/spring-cloud-config-sample/src/main/java/sample/Application.java b/spring-cloud-config-sample/src/main/java/sample/Application.java index b42ae422..5748110b 100644 --- a/spring-cloud-config-sample/src/main/java/sample/Application.java +++ b/spring-cloud-config-sample/src/main/java/sample/Application.java @@ -20,7 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.core.env.Environment; -import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; @@ -35,7 +35,7 @@ public class Application { SpringApplication.run(Application.class, args); } - @RequestMapping("/") + @GetMapping("/") public String query(@RequestParam("q") String q) { return this.environment.getProperty(q); } diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/encryption/EncryptionController.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/encryption/EncryptionController.java index 4fe88f8d..6497d98b 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/encryption/EncryptionController.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/encryption/EncryptionController.java @@ -35,11 +35,12 @@ import org.springframework.security.rsa.crypto.RsaKeyHolder; import org.springframework.security.rsa.crypto.RsaSecretEncryptor; import org.springframework.util.Base64Utils; import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; /** @@ -73,12 +74,12 @@ public class EncryptionController { this.defaultProfile = defaultProfile; } - @RequestMapping(value = "/key", method = RequestMethod.GET) + @GetMapping("/key") public String getPublicKey() { return getPublicKey(defaultApplicationName, defaultProfile); } - @RequestMapping(value = "/key/{name}/{profiles}", method = RequestMethod.GET) + @GetMapping("/key/{name}/{profiles}") public String getPublicKey(@PathVariable String name, @PathVariable String profiles) { TextEncryptor encryptor = getEncryptor(name, profiles, ""); if (!(encryptor instanceof RsaKeyHolder)) { @@ -87,19 +88,19 @@ public class EncryptionController { return ((RsaKeyHolder) encryptor).getPublicKey(); } - @RequestMapping(value = "encrypt/status", method = RequestMethod.GET) + @GetMapping("encrypt/status") public Map status() { TextEncryptor encryptor = getEncryptor(defaultApplicationName, defaultProfile, ""); validateEncryptionWeakness(encryptor); return Collections.singletonMap("status", "OK"); } - @RequestMapping(value = "encrypt", method = RequestMethod.POST) + @PostMapping("encrypt") public String encrypt(@RequestBody String data, @RequestHeader("Content-Type") MediaType type) { return encrypt(defaultApplicationName, defaultProfile, data, type); } - @RequestMapping(value = "/encrypt/{name}/{profiles}", method = RequestMethod.POST) + @PostMapping("/encrypt/{name}/{profiles}") public String encrypt(@PathVariable String name, @PathVariable String profiles, @RequestBody String data, @RequestHeader("Content-Type") MediaType type) { TextEncryptor encryptor = getEncryptor(name, profiles, ""); @@ -112,12 +113,12 @@ public class EncryptionController { return encrypted; } - @RequestMapping(value = "decrypt", method = RequestMethod.POST) + @PostMapping("decrypt") public String decrypt(@RequestBody String data, @RequestHeader("Content-Type") MediaType type) { return decrypt(defaultApplicationName, defaultProfile, data, type); } - @RequestMapping(value = "/decrypt/{name}/{profiles}", method = RequestMethod.POST) + @PostMapping("/decrypt/{name}/{profiles}") public String decrypt(@PathVariable String name, @PathVariable String profiles, @RequestBody String data, @RequestHeader("Content-Type") MediaType type) { TextEncryptor encryptor = getEncryptor(name, profiles, ""); diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/EnvironmentController.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/EnvironmentController.java index fdd6b95a..a6f5e1f4 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/EnvironmentController.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/EnvironmentController.java @@ -43,6 +43,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; +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; @@ -103,22 +104,22 @@ public class EnvironmentController { this.acceptEmpty = acceptEmpty; } - @RequestMapping(path = "/{name}/{profiles:.*[^-].*}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(path = "/{name}/{profiles:.*[^-].*}", produces = MediaType.APPLICATION_JSON_VALUE) public Environment defaultLabel(@PathVariable String name, @PathVariable String profiles) { return getEnvironment(name, profiles, null, false); } - @RequestMapping(path = "/{name}/{profiles:.*[^-].*}", produces = EnvironmentMediaType.V2_JSON) + @GetMapping(path = "/{name}/{profiles:.*[^-].*}", produces = EnvironmentMediaType.V2_JSON) public Environment defaultLabelIncludeOrigin(@PathVariable String name, @PathVariable String profiles) { return getEnvironment(name, profiles, null, true); } - @RequestMapping(path = "/{name}/{profiles}/{label:.*}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(path = "/{name}/{profiles}/{label:.*}", produces = MediaType.APPLICATION_JSON_VALUE) public Environment labelled(@PathVariable String name, @PathVariable String profiles, @PathVariable String label) { return getEnvironment(name, profiles, label, false); } - @RequestMapping(path = "/{name}/{profiles}/{label:.*}", produces = EnvironmentMediaType.V2_JSON) + @GetMapping(path = "/{name}/{profiles}/{label:.*}", produces = EnvironmentMediaType.V2_JSON) public Environment labelledIncludeOrigin(@PathVariable String name, @PathVariable String profiles, @PathVariable String label) { return getEnvironment(name, profiles, label, true); @@ -148,13 +149,13 @@ public class EnvironmentController { return Environment.normalize(part); } - @RequestMapping("/{name}-{profiles}.properties") + @GetMapping("/{name}-{profiles}.properties") public ResponseEntity properties(@PathVariable String name, @PathVariable String profiles, @RequestParam(defaultValue = "true") boolean resolvePlaceholders) throws IOException { return labelledProperties(name, profiles, null, resolvePlaceholders); } - @RequestMapping("/{label}/{name}-{profiles}.properties") + @GetMapping("/{label}/{name}-{profiles}.properties") public ResponseEntity labelledProperties(@PathVariable String name, @PathVariable String profiles, @PathVariable String label, @RequestParam(defaultValue = "true") boolean resolvePlaceholders) throws IOException { @@ -168,13 +169,13 @@ public class EnvironmentController { return getSuccess(propertiesString); } - @RequestMapping("{name}-{profiles}.json") + @GetMapping("{name}-{profiles}.json") public ResponseEntity jsonProperties(@PathVariable String name, @PathVariable String profiles, @RequestParam(defaultValue = "true") boolean resolvePlaceholders) throws Exception { return labelledJsonProperties(name, profiles, null, resolvePlaceholders); } - @RequestMapping("/{label}/{name}-{profiles}.json") + @GetMapping("/{label}/{name}-{profiles}.json") public ResponseEntity labelledJsonProperties(@PathVariable String name, @PathVariable String profiles, @PathVariable String label, @RequestParam(defaultValue = "true") boolean resolvePlaceholders) throws Exception { @@ -199,13 +200,13 @@ public class EnvironmentController { return output.toString(); } - @RequestMapping({ "/{name}-{profiles}.yml", "/{name}-{profiles}.yaml" }) + @GetMapping({ "/{name}-{profiles}.yml", "/{name}-{profiles}.yaml" }) public ResponseEntity yaml(@PathVariable String name, @PathVariable String profiles, @RequestParam(defaultValue = "true") boolean resolvePlaceholders) throws Exception { return labelledYaml(name, profiles, null, resolvePlaceholders); } - @RequestMapping({ "/{label}/{name}-{profiles}.yml", "/{label}/{name}-{profiles}.yaml" }) + @GetMapping({ "/{label}/{name}-{profiles}.yml", "/{label}/{name}-{profiles}.yaml" }) public ResponseEntity labelledYaml(@PathVariable String name, @PathVariable String profiles, @PathVariable String label, @RequestParam(defaultValue = "true") boolean resolvePlaceholders) throws Exception { diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/resource/ResourceController.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/resource/ResourceController.java index 5f118e40..877fe92b 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/resource/ResourceController.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/resource/ResourceController.java @@ -34,6 +34,7 @@ import org.springframework.http.MediaType; import org.springframework.util.StreamUtils; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.ExceptionHandler; +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; @@ -98,7 +99,7 @@ public class ResourceController { this.plainTextEncryptEnabled = plainTextEncryptEnabled; } - @RequestMapping("/{name}/{profile}/{label}/**") + @GetMapping("/{name}/{profile}/{label}/**") public String retrieve(@PathVariable String name, @PathVariable String profile, @PathVariable String label, ServletWebRequest request, @RequestParam(defaultValue = "true") boolean resolvePlaceholders) throws IOException { @@ -106,7 +107,7 @@ public class ResourceController { return retrieve(request, name, profile, label, path, resolvePlaceholders); } - @RequestMapping(value = "/{name}/{profile}/{path:.*}", params = "useDefaultLabel") + @GetMapping(value = "/{name}/{profile}/{path:.*}", params = "useDefaultLabel") public String retrieveDefault(@PathVariable String name, @PathVariable String profile, @PathVariable String path, ServletWebRequest request, @RequestParam(defaultValue = "true") boolean resolvePlaceholders) throws IOException { @@ -167,14 +168,14 @@ public class ResourceController { return retrieve(null, name, profile, label, path, resolvePlaceholders); } - @RequestMapping(value = "/{name}/{profile}/{label}/**", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) + @GetMapping(value = "/{name}/{profile}/{label}/**", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) public byte[] binary(@PathVariable String name, @PathVariable String profile, @PathVariable String label, ServletWebRequest request) throws IOException { String path = getFilePath(request, name, profile, label); return binary(request, name, profile, label, path); } - @RequestMapping(value = "/{name}/{profile}/{path:.*}", params = "useDefaultLabel", + @GetMapping(value = "/{name}/{profile}/{path:.*}", params = "useDefaultLabel", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) public byte[] binaryDefault(@PathVariable String name, @PathVariable String profile, @PathVariable String path, ServletWebRequest request) throws IOException {