Questions tagged [spring-restcontroller]

@RestController is Spring MVC's shortcut annotation for creating Rest Controllers. Use this tag for questions relating to the use of this annotation.

@RestController is an Spring annotation that is used to declare controllers where all @RequestMapping annotated methods assume @ResponseBody semantics by default.

Useful links:

1579 questions
3
votes
1 answer

Streaming a POI SXSSFWorkbook to the servlet output stream

We are building a Spring boot REST endpoint that generates a large XLS file (may contain ~ 1mil lines) and provides it for download. The current solution uses the SXSSF API of Apache POI library for creating the workbook; after that we write the…
chirina
  • 133
  • 2
  • 8
3
votes
3 answers

KeycloakRestTemplate with spring application

I have a spring client with spring rest api's which are protected with keycloak. I am trying to call it using keycloakresttemplate from another client which is a pure java code with no security. I am getting the keycloak access token from java…
3
votes
4 answers

Configure FAIL_ON_UNKNOWN_PROPERTIES for each RequestMapping differently in the Controller

I want to handle json to Object conversion differently on different @RequestMapping in my Controller. I believe if we add Jackson dependency in our spring-boot project it handles json to Object conversion and…
3
votes
1 answer

Spring Boot Rest Controller vs Camel rest dsl

I'm developing a new application which is Spring Boot with camel. I am exposing REST endpoints as part of this application. I'm little confused to choose between these two options: Spring Rest Controller --> Spring service with producer template…
3
votes
0 answers

Why instrumented Spring REST Controller thread waiting on a lock?

We have a Spring Boot Application (v2.0.7) using REST Controller and JPA with EclipseLink. In one of the tests we made the DB not accessible, which in a few minutes led to the app not responding to REST requests at all. A Thread Dump was taken which…
3
votes
4 answers

Swagger return response: "can't parse JSON. Raw result:"

I am not sure why this is happening. My return statement for spring boot rest controller is something like below return ResponseEntity.status(HttpStatus.OK).body("Successfully added"); Now on swagger UI i see response as below can't parse JSON. …
user9735824
  • 1,196
  • 5
  • 19
  • 36
3
votes
0 answers

Response not coming back from one service to another service - microservices

I am facing strange issue where response as string not coming back from one service to another service. we have created microservices where one service is calling another service. i can see response printed in logs . after that line immediately i am…
3
votes
1 answer

Multipart file (not given condition).Error-400(bad request)

My rest api is. @PutMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUEpath="/{referenceNumber}") public void updateCard(@RequestHeader(value = tenantId) String theTenantId, @PathVariable String referenceNumber,@RequestParam(value =…
3
votes
1 answer

Jackson InvalidFormatException: Cannot deserialize value of type `java.util.UUID` from String

Am using Spring boot with a Rest Controller. I have a @PostMapping with a @RequestBody having object that has id of type UUID. When I am trying to test my post request from Postman I get the following error. JSON parse error: Cannot deserialize…
VC2019
  • 427
  • 1
  • 5
  • 9
3
votes
3 answers

How to implement and limit API calls per second in Spring Rest

I have spring batch application with spring MVC. In this application, I have to call Google API. There is a restriction of max 4 req per sec for API. Now I have to call google API from inside the spring batch. So I have two questions. q1: How can I…
Vimit Dhawan
  • 597
  • 1
  • 7
  • 25
3
votes
3 answers

How to map dynamic query parameters in Spring Boot RestController

Is it possible to map query parameters with dynamic names using Spring Boot? I would like to map parameters such as these: /products?filter[name]=foo /products?filter[length]=10 /products?filter[width]=5 I could do something like this, but it would…
james246
  • 1,884
  • 1
  • 15
  • 28
3
votes
1 answer

Intermittent RestRepositoryController 404 issue with Spring Boot 1.5.10?

I am experiencing a strange issue with Spring boot and one controller. I believe it is due to a conflict with another controller which is similarly named (a newer version) The structure is like so controllers -v2 …
tomaytotomato
  • 3,788
  • 16
  • 64
  • 119
3
votes
1 answer

Creating a replacement rest controller in spring with same name, causes bean name conflict?

Long story short, I want to replace the existing controller in spring boot because it is not satisfactory. Therefore I have created a new rest controller class and have started adding functionality to it. I want to maintain the older controller…
tomaytotomato
  • 3,788
  • 16
  • 64
  • 119
3
votes
3 answers

Is it possible to split request params in Spring controllers?

I have a request like: example.com/search?sort=myfield1,-myfield2,myfield3 I would like to split those params to bind a List sort in my controller or List where SortParam is the class with fields like: name (String) and ask…
Oleksandr
  • 3,574
  • 8
  • 41
  • 78
3
votes
1 answer

spring REST RequestMethod how to Map a http LOCK and UNLOCK RequestMapping?

seems that this is the same as Custom HTTP Methods in Spring MVC I need to implement a call with http method LOCK and UNLOCK. currently spring's requestMethod only supports public enum RequestMethod { GET, HEAD, POST, PUT, PATCH, DELETE,…