replace requestmapping, update properties

This commit is contained in:
Loredana Crusoveanu 2018-05-06 23:02:49 +03:00
parent b4d4d4ec08
commit 88a3f6c0fe
15 changed files with 43 additions and 52 deletions

View File

@ -1,4 +1,2 @@
server.port=9090
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto = update

View File

@ -20,7 +20,6 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
- [Dynamic DTO Validation Config Retrieved from DB](http://www.baeldung.com/spring-dynamic-dto-validation)
- [Custom Information in Spring Boot Info Endpoint](http://www.baeldung.com/spring-boot-info-actuator-custom)
- [Using @JsonComponent in Spring Boot](http://www.baeldung.com/spring-boot-jsoncomponent)
- [Create a Custom Auto-Configuration with Spring Boot](http://www.baeldung.com/spring-boot-custom-auto-configuration)
- [Testing in Spring Boot](http://www.baeldung.com/spring-boot-testing)
- [Guide to @ConfigurationProperties in Spring Boot](http://www.baeldung.com/configuration-properties-in-spring-boot)
- [How to Get All Spring-Managed Beans?](http://www.baeldung.com/spring-show-all-beans)

View File

@ -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(

View File

@ -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());

View File

@ -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);

View File

@ -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);

View File

@ -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";
}

View File

@ -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";
}

View File

@ -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!";

View File

@ -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";
}

View File

@ -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();
}

View File

@ -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";
}

View File

@ -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!!!";
}

View File

@ -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.";
}

View File

@ -1,21 +1,22 @@
server.port=9090
server.contextPath=/springbootapp
management.port=8081
management.address=127.0.0.1
server.servlet.contextPath=/springbootapp
management.server.port=8081
management.server.address=127.0.0.1
#debug=true
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto = update
endpoints.shutdown.enabled=true
endpoints.jmx.domain=Spring Sample Application
endpoints.jmx.uniqueNames=true
management.endpoints.jmx.domain=Spring Sample Application
management.endpoints.jmx.uniqueNames=true
management.endpoint.shutdown.enabled=true
##jolokia.config.debug=true
##endpoints.jolokia.enabled=true
##endpoints.jolokia.path=jolokia
spring.jmx.enabled=true
endpoints.jmx.enabled=true
management.endpoints.jmx.enabled=true
## for pretty printing of json when endpoints accessed over HTTP
http.mappers.jsonPrettyPrint=true
@ -26,11 +27,7 @@ info.app.description=This is my first spring boot application G1
info.app.version=1.0.0
info.java-vendor = ${java.specification.vendor}
## Spring Security Configurations
security.user.name=admin1
security.user.password=secret1
management.security.role=SUPERUSER
management.endpoint.shutdown.enabled=true
logging.level.org.springframework=INFO
@ -38,15 +35,12 @@ logging.level.org.springframework=INFO
servlet.name=dispatcherExample
servlet.mapping=/dispatcherExampleURL
#banner.charset=UTF-8
#banner.location=classpath:banner.txt
#banner.image.location=classpath:banner.gif
#banner.image.width= //TODO
#banner.image.height= //TODO
#banner.image.margin= //TODO
#banner.image.invert= //TODO
#spring.banner.charset=UTF-8
#spring.banner.location=classpath:banner.txt
#spring.banner.image.location=classpath:banner.gif
#spring.banner.image.width= //TODO
#spring.banner.image.height= //TODO
#spring.banner.image.margin= //TODO
#spring.banner.image.invert= //TODO
contactInfoType=email
endpoints.beans.id=springbeans
endpoints.beans.sensitive=false