replace requestmapping, update properties
This commit is contained in:
@@ -6,6 +6,7 @@ import java.util.UUID;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -22,7 +23,7 @@ public class UserController {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(UserController.class);
|
||||
|
||||
@RequestMapping("")
|
||||
@GetMapping("")
|
||||
public List<User> getAllUsers() {
|
||||
LOG.info("Fetching all the users");
|
||||
return Arrays.asList(
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.util.Map;
|
||||
|
||||
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 com.baeldung.displayallbeans.service.FooService;
|
||||
|
||||
@@ -13,7 +13,7 @@ public class FooController {
|
||||
@Autowired
|
||||
private FooService fooService;
|
||||
|
||||
@RequestMapping(value = "/displayallbeans")
|
||||
@GetMapping(value = "/displayallbeans")
|
||||
public String getHeaderAndBody(Map<String, Object> model) {
|
||||
model.put("header", fooService.getHeader());
|
||||
model.put("message", fooService.getBody());
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.baeldung.errorhandling.controllers;
|
||||
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import javax.servlet.RequestDispatcher;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -13,7 +13,7 @@ public class MyErrorController implements ErrorController {
|
||||
|
||||
public MyErrorController() {}
|
||||
|
||||
@RequestMapping(value = "/error")
|
||||
@GetMapping(value = "/error")
|
||||
public String handleError(HttpServletRequest request) {
|
||||
|
||||
Object status = request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.baeldung.git;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -19,7 +19,7 @@ public class CommitInfoController {
|
||||
@Value("${git.commit.id}")
|
||||
private String commitId;
|
||||
|
||||
@RequestMapping("/commitId")
|
||||
@GetMapping("/commitId")
|
||||
public Map<String, String> getCommitId() {
|
||||
Map<String, String> result = new HashMap<>();
|
||||
result.put("Commit message", commitMessage);
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package com.baeldung.intro.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class HomeController {
|
||||
|
||||
@RequestMapping("/")
|
||||
@GetMapping("/")
|
||||
public String root() {
|
||||
return "Index Page";
|
||||
}
|
||||
|
||||
@RequestMapping("/local")
|
||||
@GetMapping("/local")
|
||||
public String local() {
|
||||
return "/local";
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.baeldung.rss;
|
||||
|
||||
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.RequestMethod;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(value = "/rss", produces = "application/*")
|
||||
public class ArticleRssController {
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
@GetMapping
|
||||
public String articleFeed() {
|
||||
return "articleFeedView";
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@SpringBootApplication
|
||||
@@ -27,7 +27,7 @@ public class WarInitializerApplication extends SpringBootServletInitializer {
|
||||
@RestController
|
||||
public static class WarInitializerController {
|
||||
|
||||
@RequestMapping("/")
|
||||
@GetMapping("/")
|
||||
public String handler(Model model) {
|
||||
model.addAttribute("date", LocalDateTime.now());
|
||||
return "WarInitializerApplication is up and running!";
|
||||
|
||||
@@ -2,12 +2,12 @@ package com.baeldung.webjar;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
public class TestController {
|
||||
|
||||
@RequestMapping(value = "/")
|
||||
@GetMapping(value = "/")
|
||||
public String welcome(Model model) {
|
||||
return "index";
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
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.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@@ -26,18 +25,18 @@ public class GenericEntityController {
|
||||
entityList.add(new GenericEntity(4l, "entity_4"));
|
||||
}
|
||||
|
||||
@RequestMapping("/entity/all")
|
||||
@GetMapping("/entity/all")
|
||||
public List<GenericEntity> findAll() {
|
||||
return entityList;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/entity", method = RequestMethod.POST)
|
||||
@PostMapping("/entity")
|
||||
public GenericEntity addEntity(GenericEntity entity) {
|
||||
entityList.add(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
@RequestMapping("/entity/findby/{id}")
|
||||
@GetMapping("/entity/findby/{id}")
|
||||
public GenericEntity findById(@PathVariable Long id) {
|
||||
return entityList.stream().filter(entity -> entity.getId().equals(id)).findFirst().get();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.baeldung.common.error;
|
||||
|
||||
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
public class MyCustomErrorController implements ErrorController {
|
||||
|
||||
@@ -11,7 +11,7 @@ public class MyCustomErrorController implements ErrorController {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@RequestMapping(value = PATH)
|
||||
@GetMapping(value = PATH)
|
||||
public String error() {
|
||||
return "Error heaven";
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.baeldung.common.error.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@@ -9,12 +9,12 @@ public class ErrorController {
|
||||
public ErrorController() {
|
||||
}
|
||||
|
||||
@RequestMapping("/400")
|
||||
@GetMapping("/400")
|
||||
String error400() {
|
||||
return "Error Code: 400 occured.";
|
||||
}
|
||||
|
||||
@RequestMapping("/errorHeaven")
|
||||
@GetMapping("/errorHeaven")
|
||||
String errorHeaven() {
|
||||
return "You have reached the heaven of errors!!!";
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@@ -23,7 +23,7 @@ public class SpringBootApplication {
|
||||
|
||||
private static ApplicationContext applicationContext;
|
||||
|
||||
@RequestMapping("/")
|
||||
@GetMapping("/")
|
||||
String home() {
|
||||
return "TADA!!! You are in Spring Boot Actuator test application.";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user