Difference between @EntityScan and @ComponentScan

The @ComponentScan annotation is used to automatically create beans for every class annotated with @Component, @Service, @Controller, @RestController, @Repository, … and adds them to the Spring container (allowing them to be @Autowired). The @EntityScan on the other hand does not create beans as far as I know. It only identifies which classes should be used … Read more

When use AbstractAnnotationConfigDispatcherServletInitializer and WebApplicationInitializer?

With the release of the Servlet 3.0 spec it became possible to configure your Servlet Container with (almost) no xml. For this there is the ServletContainerInitializer in the Servlet specification. In this class you can register filters, listeners, servlets etc. as you would traditionally do in a web.xml. Spring provides a an implementation the SpringServletContainerInitializer … Read more

Ambiguous @ExceptionHandler method mapped for [class org.springframework.web.bind.MethodArgumentNotValidException]

Springs ResponseEntityExceptionHandler has a method handleException which is annotated with : @ExceptionHandler({ … MethodArgumentNotValidException.class, … }) Your method handleMethodArgumentNotValidException is also annotated to handle MethodArgumentNotValidException. So spring finds two methods that should be used to handle the same exception, that is the reason for the exception. **Solution ** Do not add a new method handleMethodArgumentNotValidException … Read more

Difference between the annotations @GetMapping and @RequestMapping(method = RequestMethod.GET)

@GetMapping is a composed annotation that acts as a shortcut for @RequestMapping(method = RequestMethod.GET). @GetMapping is the newer annotaion. It supports consumes Consume options are : consumes = “text/plain” consumes = {“text/plain”, “application/*”} For Further details see: GetMapping Annotation or read: request mapping variants RequestMapping supports consumes as well GetMapping we can apply only on … Read more

When use ResponseEntity and @RestController for Spring RESTful applications

ResponseEntity is meant to represent the entire HTTP response. You can control anything that goes into it: status code, headers, and body. @ResponseBody is a marker for the HTTP response body and @ResponseStatus declares the status code of the HTTP response. @ResponseStatus isn’t very flexible. It marks the entire method so you have to be … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)