spring-restcontroller

Parameter value [1] did not match expected type

非 Y 不嫁゛ 提交于 2019-12-13 03:23:34
问题 In the Spring-boot project I try to pass as a request parameter a Date object and get this error: Parameter value [1] did not match expected type [java.util.Date (n/a)] This is the http-requset that i send: http://localhost:8080/moneyManager/customer/actionBetweenDates?startDate=2019/07/01&endDate=2019/07/30 This is the fuction that trigger in the rest: @RequestMapping(path="actionBetweenDates", method=RequestMethod.GET) public Collection<Action> getActionByDate(@RequestParam Date startDate,

what would be the reason not detecting RestController for some requests

大城市里の小女人 提交于 2019-12-13 03:19:31
问题 I am using spring boot 2.1.7 Release and trying to create a simple rest application . Somehow this RestController is not detected by the request from third party vandor application while is detected by curl commend from same host and soapUI. @RestController public class SendController { private static final Logger log = LoggerFactory.getLogger(SendController.class); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("MM/dd/yyyy"); @PostMapping("/Message") public ResponseEntity

Spring Boot, Maven, disable specific RestController in the derived project

梦想的初衷 提交于 2019-12-13 03:00:03
问题 In my Maven, Spring Boot 2 project I have Maven module called api1 . I have declared a number of @RestController s there. In order to extend the logic of the api1 module, I have implemented another Maven module called api2 and placed api1 there as Maven dependency. Right now all of the @RestController s from api1 project are initialized in the api2 because all of them are present on the api2 classpath. How to disable a certain @RestController in api2 project? 回答1: I think the crucial fact

How do I serialize using two different getters based on JsonView in RestController?

孤街醉人 提交于 2019-12-13 00:47:59
问题 I want the ability to serialize a field in an object based on the JsonView. It doesn't have to be JsonView, it's just what I have been exploring. Basically using @JsonView annotation on RestController class, it would serialize my POJO. However I have a User and Admin view where there is an object: Map secrets; That for an Admin view I want both key:value to show up and serialize, but for a User I would only want a List keys or if its simpler, keep Map but only show the key and all of the

Difference between parameters taken by @RestController and @RequestMapping annotations?

╄→гoц情女王★ 提交于 2019-12-12 19:22:28
问题 What does the parameter in @RestController("/path/..") do? Does it not set the base path like @RequestMapping("/path/..") . What is the difference? @RestController("base-path") 回答1: In case of @RestController the parameter value depicts the component name or bean name, whereas in @RequestMapping the value parameter is used to specify the path. Both are used for different purpose. If you want to specify request URI path on controller class name use @RequestMapping annotation with

How @RequestMapping internally works in Spring Boot?

戏子无情 提交于 2019-12-12 14:47:45
问题 @RestController @RequestMapping("/employee") public class Employee { @RequestMapping("/save") public void saveEmployee() { // saving employee } } How does @RequestMapping will work internally to map the request to the saveEmployee method? 回答1: During application startup, Spring will identify all Bean s by way of XML Config, Java Config, or Component Scanning and store them in the ApplicationContext . Spring Boot autoconfigures many Beans for you, including RequestMappingHandlerMapping. When

Using a map to set parameters for a rest call using RestTemplate

时光怂恿深爱的人放手 提交于 2019-12-12 10:39:43
问题 I am currently using a piece of code to set parameters and I do a REST call to a URL using restTemplate, it works fine: MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>(); map.add("grant_type", grantType); map.add("client_id", clientId); map.add("client_secret", clientSecret); HttpEntity<?> entity = new HttpEntity<Object>(map); restTemplate.exchange("myurl", HttpMethod.POST, entity, Void.class); But if I am using a LinkedMultiValueMap it's because I looked on the

Difference between path and value in spring boot Requestmapping

跟風遠走 提交于 2019-12-12 09:29:18
问题 What is the difference between below two and which on to Use when ? @GetMapping(path = "/usr/{userId}") public String findDBUserGetMapping(@PathVariable("userId") String userId) { return "Test User"; } @RequestMapping(value = "/usr/{userId}", method = RequestMethod.GET) public String findDBUserReqMapping(@PathVariable("userId") String userId) { return "Test User"; } 回答1: As mentioned in the comments (and the documentation), value is an alias to path . Spring often declares the value element

Avoiding default basic-error-controller from swagger api [duplicate]

淺唱寂寞╮ 提交于 2019-12-12 07:14:38
问题 This question already has answers here : Remove Basic Error Controller In SpringFox SwaggerUI (7 answers) Closed 5 months ago . I'm using swagger2 in my spring boot project. It's working well, but I need to exclude the basic-error-controller from the api. Currently I'm using the following code using regex. It's working but is there any perfect way to do this. CODE : @Bean public Docket demoApi() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.any())

spring jpa embeddable class send int instead of Object

拜拜、爱过 提交于 2019-12-12 03:25:14
问题 I have a little problem between my RestController response and my AngularJs Controller. First, I'm calling my rest webservice with $http : myModule.controller('UserDetailsCtrl',function($http, idUser){ var self = this; $http.post('/get-user-details', idUser).then( function(response){ self.clients = response.data.usersClients; for(client of self.clients){ console.log("pkUsersClients : " + client.pkUsersClients); // console display "[object Object]" console.log("client : " + client