Latest Questions tagged Spring

Browse all latest questions tagged Spring

101
Votes
Published 07 Sep, 2022
Java - How to filter a PostgreSQL array column with the JPA Criteria API?

I am using: Hibernate 4.3.5 Spring JPA 1.6.0 Javax Persistence API 2.1 The "refcodemailing" column is defined as an array of int: int[] My entity object: @Entity @Table public class CalendarEven...

24
Votes
Published 19 Sep, 2022
Java - Connecting to Heroku Postgres from Spring Boot

I'm looking for the simplest, cleanest way of connecting to Heroku Postgres in a Spring Boot app using JPA/Hibernate. I don't see a good, complete example for this combo in either Heroku or Spring Bo...

72
Votes
Published 16 Sep, 2022
Java - org.mockito.exceptions.base.MockitoException: Please ensure that the type 'UserRestService' has a no-arg constructor

I want to create JUnit5 tests for Rest API. @Test public void resetRequest_NAME_AND_EMAIL_MISMATCH() throws Exception { when(userRestService.resetRequest(anyString(), anyString())).thenReturn(Boo...

73
Votes
Published 06 Sep, 2022
Java - How to map Page<ObjectEntity> to Page<ObjectDTO> in spring-data-rest

When I hit the database with PagingAndSortingRepository.findAll(Pageable) I get Page&lt;ObjectEntity&gt;. However, I want to expose DTO's to the client and not entities. I can create DTO just by injec...

11
Votes
Published 07 Sep, 2022
Java - how to capture connection event in my webSocket server with Spring 4?

I did a simple web socket communication with spring 4,STOMP and sock.js, following this https://github.com/rstoyanchev/spring-websocket-portfolio and this http://assets.spring.io/wp/WebSocketBlogPost....

79
Votes
Published 07 Sep, 2022
Java - Spring: Generic RowMapper for dynamic queries

I am using SpringBatch to read from Oracle and write into ElasticSearch. My code works fine for static queries. Example: select emp_id, emp_name from employee_table I have a RowMapper class that maps...

12
Votes
Published 07 Sep, 2022
Java - How to inject a Map using the @Value Spring Annotation?

How can I inject values into a Map from the properties file using the @Value annotation in Spring? My Spring Java class is and I tried using the $, but got the following error message: Could not auto...

122
Votes
Published 07 Sep, 2022
Java - Error: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'text/plain;charset=UTF-8' not supported

I'm newbie in Spring Data. I keep getting the error: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'text/plain;charset=UTF-8' not supported I've tried to change consumes ins...

60
Votes
Published 02 Sep, 2022
Java - Reading HTTP headers in a Spring REST controller

I am trying to read HTTP headers in Spring based REST API. I followed this. But I am getting this error: No message body reader has been found for class java.lang.String, ContentType: applicatio...

61
Votes
Published 07 Sep, 2022
Java - Prevent default formatting (comma insertion) of long argument in s:message tag

I have a jsp in which I use spring s:message tag &lt;s:message code="application.success" arguments="${applicationRefId}" /&gt; applicationRefId is a long variable added to the model. In my resou...

38
Votes
Published 15 Sep, 2022
Java - My Spring jpaRepository throws a TransactionRequiredException when i'm trying to delete an object

I have a RESTcontroller that has a delete mapping like so: @DeleteMapping(&quot;/deleterequest/{custId}&quot;) //@Transactional public ResponseEntity&lt;?&gt; delete(@PathVariable long cus...

38
Votes
Published 15 Sep, 2022
Java - How do I specify a BeanNamingStrategy with Spring Boot?

I want to specify a custom BeanNamingStrategy while configuring my application with Spring Boot. By default, Spring Boot uses the MethodNameStrategy which is a BeanNamingStrategy. The reason I want t...

83
Votes
Published 15 Sep, 2022
Java - How to apply the PathPatternParser introduced in Spring 5?

I want to create a GET request that takes a filepath as a path variable. As described in the Spring documentation found here, this should be possible by using the following: /resources/{*path}. I a...

94
Votes
Published 15 Sep, 2022
Java - Java: Image upload with JavaScript - File is damaged, corrupted or too large

I am using Spring Boot as backend server and I have a JavaScript frontend. For sending data between front- and backend I'm using the Axios library, which usually works pretty fine. The Problem: The...

25
Votes
Published 07 Sep, 2022
Java - Spring Batch - how to generate Output file of a batch job as excel sheet

I have a simple spring batch program which reads data from a INPUT file and writes to OUTPUT file. Input file is having 50000 records and my chunk size is 1000. There are five columns in the input f...