How-to articles, tricks, and solutions about SPRING-MVC

@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.

could not extract ResultSet in hibernate

If you are trying to execute a query using Hibernate and are getting an error saying "could not extract ResultSet," it could be due to a few different issues:

How to respond with an HTTP 400 error in a Spring MVC @ResponseBody method returning String

To respond with an HTTP 400 error in a Spring MVC controller method that returns a String, you can throw a ResponseStatusException with a status of BAD_REQUEST.

How to solve the “failed to lazily initialize a collection of role” Hibernate exception

The "failed to lazily initialize a collection of role" exception in Hibernate is thrown when you try to access an uninitialized collection from a Hibernate entity when the entity is in a detached state.

How to upload a file and JSON data in Postman?

To upload a file and JSON data in Postman, you can follow these steps:

Redirect to an external URL from controller action in Spring MVC

To redirect to an external URL from a controller action in Spring MVC, you can use the RedirectView class and return it from the controller action.

Spring MVC - How to return simple String as JSON in Rest Controller

To return a simple string as JSON in a Spring MVC Rest Controller, you can use the @ResponseBody annotation and return the string directly.

UnsatisfiedDependencyException: Error creating bean with name

UnsatisfiedDependencyException is a runtime exception that is thrown when the Spring framework is unable to resolve a dependency for a bean.

Using env variable in Spring Boot's application.properties

You can use environment variables in your application.properties file by using the spring.profiles.active property.

What is @ModelAttribute in Spring MVC?

In Spring MVC, the @ModelAttribute annotation is used to bind request parameters to method arguments in controller methods.

What's the difference between @Component, @Repository & @Service annotations in Spring?

In Spring, the @Component annotation is used to mark a Java class as a candidate for component scanning. The @Repository annotation is a specialization of @Component for use in the persistence layer.