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

Can @Component, @Repository and @Service annotations be used interchangeably in Spring or do they provide any particular functionality besides acting as a notation device? In other words, if I have a Service class and I change the annotation from @Service to @Component, will it still behave the same way? Or does the annotation also influence … Read more

How do I POST JSON data with cURL?

I use Ubuntu and installed cURL on it. I want to test my Spring REST application with cURL. I wrote my POST code at the Java side. However, I want to test it with cURL. I am trying to post a JSON data. Example data is like this: {“value”:”30″,”type”:”Tip 3″,”targetModule”:”Target 3″,”configurationGroup”:null,”name”:”Configuration Deneme 3″,”description”:null,”identity”:”Configuration Deneme 3″,”version”:0,”systemId”:3,”active”:true} … Read more

Spring Boot – Unable to resolve Whitelabel Error Page

Please define method in your controller: You may define @RequestMapping(value = “/”, method = RequestMethod.GET) or you may directly use @GetMapping @Controller public class LoginController { @GetMapping(path=”/”) public String login() { System.out.println(“******************logging************************”); return “login”; } } there might be some more conflicts in your pom, like no need add tomcat dependency as its already embedded so below … Read more

org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘MyController’:

Copied from the stacktrace: BeanInstantiationException: Could not instantiate bean class [com.gestEtu.project.model.dao.CompteDAOHib]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.gestEtu.project.model.dao.CompteDAOHib.<init>() By default, Spring will try to instantiate beans by calling a default (no-arg) constructor. The problem in your case is that the implementation of the CompteDAOHib has a constructor with a SessionFactory argument. By adding the @Autowired annotation to a constructor, … Read more

Spring boot – Request method ‘POST’ not supported. Tried everything

Following might help. While you deploy the application, spring boot displays all the available services on the console. Check the POST method to create is being displayed or not. Check that there shouldn’t be any contradiction with other services. GET/PUT/POST If there are services not deployed, try adding ‘/’ before other services – GET, PUT, … Read more

Difference between spring @Controller and @RestController annotation

@Controller is used to mark classes as Spring MVC Controller. @RestController is a convenience annotation that does nothing more than adding the @Controller and @ResponseBody annotations (see: Javadoc) So the following two controller definitions should do the same @Controller @ResponseBody public class MyController { } @RestController public class MyRestController { }

UnsatisfiedDependencyException: Error creating bean with name

The ClientRepository should be annotated with @Repository tag. With your current configuration Spring will not scan the class and have knowledge about it. At the moment of booting and wiring will not find the ClientRepository class. EDIT If adding the @Repository tag doesn’t help, then I think that the problem might be now with the ClientService and ClientServiceImpl. Try to annotate the ClientService (interface) with @Service. … Read more