How-to articles, tricks, and solutions about SPRING
'Field required a bean of type that could not be found.' error spring restful API using mongodb
The 'Field required a bean of type that could not be found' error in a Spring application typically indicates that the application is trying to inject a dependency into a field, but it cannot find a bean of the required type in the application context.
@Autowired - No qualifying bean of type found for dependency
No qualifying bean of type found for dependency is an error message that can occur when you are using the @Autowired annotation in Spring to inject a bean dependency.
@RequestParam vs @PathVariable
In Spring MVC, the @RequestParam annotation is used to bind a request parameter to a method parameter.
Add context path to Spring Boot application
To add a context path to a Spring Boot application, you can use the server.context-path property in the application's application.properties file.
Can not deserialize instance of java.util.ArrayList out of START_OBJECT token
This error is usually encountered when trying to parse a JSON string that does not start with a JSON array, but rather a JSON object.
Downloading a file from spring controllers
To download a file from a Spring controller, you can use the ResponseEntity class along with the InputStreamResource class.
Get list of JSON objects with Spring RestTemplate
To get a list of JSON objects using the Spring RestTemplate, you can use the exchange() method to send an HTTP GET request to the server, and then use the getBody() method of the ResponseEntity object to retrieve the list of objects.
How can I log SQL statements in Spring Boot?
To log SQL statements in Spring Boot, you can configure the logging level of the org.hibernate.SQL logger to DEBUG or TRACE.
How to check String in response body with mockMvc
To check a string in the response body with MockMvc, you can use the andExpect() method of the MockMvcResultMatchers class.
How to configure port for a Spring Boot application
To configure the port for a Spring Boot application, you can use the server.port property in the application's configuration file. The configuration file can be a application.properties file in the classpath, or a application.yml file in the classpath.