spring-rest

java.lang.VerifyError: Cannot inherit from final class when using spring boot data solr

≡放荡痞女 提交于 2020-01-07 07:42:32
问题 I have a rest web service that running with spring boot 1.4.2.RELEASE. I trying to use spring data solr with my project but I am getting a VerifyError. Caused by: java.lang.VerifyError: Cannot inherit from final class at java.lang.ClassLoader.defineClass1(Native Method) ~[na:1.8.0_40-ea] at java.lang.ClassLoader.defineClass(ClassLoader.java:760) ~[na:1.8.0_40-ea] at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[na:1.8.0_40-ea] at java.net.URLClassLoader.defineClass

Decoding body parameters with Spring

折月煮酒 提交于 2020-01-04 04:41:07
问题 I'm developing a REST API backend with Spring for a Slack App. I was able to receive messages from Slack (the slash commands) but I'm not able to properly receive component interactions (button clicks). The official documentation says: Your Action URL will receive a HTTP POST request, including a payload body parameter, itself containing an application/x-www-form-urlencoded JSON string. therefore I have written the following @RestController : @RequestMapping(method = RequestMethod.POST, value

Spring RestTemplate (setBufferRequestBody as false) does not like MultiValueMap request body, which contains an InputStream object

假如想象 提交于 2020-01-01 12:18:07
问题 I am trying to forward a very large csv formatted file in a service to service manner. So, a user uploads a very large csv file (several GBs) that the backend receives as Spring's MultipartFile abstraction (my version is spring-web-4.3.3.RELEASE ). After that I forward the same MultipartFile through input stream to a different service using RestTemplate . All works fine, if setBufferRequestBody is true in request factory, but as expected, it blows up memory with out of memory error as file

Spring RestTemplate and generic types ParameterizedTypeReference collections like List<T>

天大地大妈咪最大 提交于 2019-12-29 05:41:06
问题 An Abstract controller class requires List of objects from REST. While using Spring RestTemplate its not mapping it to required class instead it returns Linked HashMAp public List<T> restFindAll() { RestTemplate restTemplate = RestClient.build().restTemplate(); ParameterizedTypeReference<List<T>> parameterizedTypeReference = new ParameterizedTypeReference<List<T>>(){}; String uri= BASE_URI +"/"+ getPath(); ResponseEntity<List<T>> exchange = restTemplate.exchange(uri, HttpMethod.GET, null

How to switch Database on runtime in SpringBoot and SpringDataJPA / Hibernate?

≯℡__Kan透↙ 提交于 2019-12-29 01:45:06
问题 I want to create an application with SpringBoot, SpringRest, SpringDataJPA / Hibernate with multiple databases on runtime. Actually i am creating multitenant application with following flow: 1- one Applcation may be php: from website user will create account, the system will run the process and will create database and releated configuration. 2- Major application ( SpringBoot, SpringRest, SpringDataJPA / hibernate ) will now loaded start pointing to that newly created database which contains

Spring Security - “Error: Forbidden” response from rest endpoint

一笑奈何 提交于 2019-12-25 16:38:06
问题 I'm setting up Spring Security in my project and I'm having some trouble hitting one of my rest endpoints. I receive an "Error: Forbidden" response from the server when I hit the endpoint through my client. What I'm doing is going to the login page (I assume at this point I'm an anonymous user with ROLE_ANONYMOUS) and clicking a tab that shows me a create new account form. When I fill out the fields and hit submit then the rest endpoint is called and the JSON data is sent to the server. In my

Is it better to pass back String or Object in the ResponseEntity<>?

自古美人都是妖i 提交于 2019-12-25 09:29:02
问题 I have a controller that returns ResponseEntity. Now I have altered this code and added a bunch of filters using ObjectMapper. After this change I am returning a String as the response. Sample code below: public ResponseEntity<String> search() { SearchResult searchResults = service.search(criteria); objectMapper.setFilterProvider(new SimpleFilterProvider() .addFilter("firstFilter", new FirstFilter()) .addFilter("secondFilter",new SecondFilter())); return new ResponseEntity<>(objectMapper

SpringBoot TestRestTemplate and LocalDateTime not working

六眼飞鱼酱① 提交于 2019-12-25 03:12:25
问题 I am using LocalDateTime in my model, after including LocalDateTimeDeserializer, converted the bean field to @NotNull @Column(name = "created") @JsonDeserialize(using = LocalDateTimeDeserializer.class) private LocalDateTime created; and included the spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS = false property in the SpringBoot's application.properties file, the application is finally able to deserialize the JSON and show properly like, "created": "2018-04-22T21:21:53.025", But,

JPA foreign key is null in the child table

百般思念 提交于 2019-12-24 18:40:18
问题 I have below classes i am trying to get onetomany relationship using JPA. When the xml message sent to restcontroller, the message is stored both parent and child table but foreign key is always null. Please let me know if any issue. Rest Service which i am using to persist the data and the below is the sample xml which i am posting to this rest method. @RequestMapping(value="/team/", method = RequestMethod.POST , headers="Accept=application/xml") @ResponseStatus(value = HttpStatus.OK) public

Spring RestTemplate receives “401 Unauthorized”

二次信任 提交于 2019-12-24 12:30:20
问题 I am using the following to retrieve JSON via RestTemplate in Spring 4: protected DocInfoResponse retrieveData(String urlWithAuth) { RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Basic " + auth.getSig()); HttpEntity<String> request = new HttpEntity<String>(headers); ResponseEntity<DocInfoResponse> response = restTemplate.exchange(urlWithAuth, HttpMethod.GET, request, DocInfoResponse.class); return response.getBody(); } I