Skip to content
Advertisement

Tag: annotations

What will happen if we interchange @service and @repository annotation in the spring MVC

Why we needs to use @service inside the service Implementation and @repository in the DAO Implementation. There are no problem occur when I interchange the @service and @repository annotation in the spring MVC. Answer According to documentaion @Repository,@Service,@Controller are all synonyms. They all are just specializations of @Component annotation. So, generally, they can be used one instead of other. But

spring combine two validation annotations in one

I’m using Spring+Hibernate+Spring-MVC. I want to define a custom constraint combining two other predefined validation annotations: @NotNull @Size like this: and I want to use this annotation in my form models. UserController.java But it does not work. It accepts the less than 4 character passwords. How can I solve this problem? Answer This is a bit late, but technique of

Spring MVC request and response flow explanation

I can’t find correct client request flow in below syntax.Could someone please clarify what is happening here? If possible please specify what are the corresponding spring classes/interfaces used in spring MVC process. Answer Request will be received by DispatcherServlet. DispatcherServlet will take the help of HandlerMapping and get to know the @Controller class name associated with the given request. So

intellij incorrectly saying no beans of type found for autowired repository

I have created a simple unit test but IntelliJ is incorrectly highlighting it red. marking it as an error No beans? As you can see below it passes the test? So it must be Autowired? Answer I had this same issue when creating a Spring Boot application using their @SpringBootApplication annotation. This annotation represents @Configuration, @EnableAutoConfiguration and @ComponentScan according to

Best practice for configuring Spring LdapTemplate via annotations instead of XML?

For a Spring Boot application, I successfully configured a Spring LdapTemplate using annotations, including the LdapContextSource dependency with @Values from application.properties. (Woot! I couldn’t find an example, so maybe this will help others.) The snippets (below) setup the context source, inject it into an LdapTemplate, and autowire that into my DirectoryService. Is there a better/cleaner way to setup the ContextSource

Override transactional method

I have method M with @Transactional in service A. I have service B extends A with overrided method M. Will be overrided method M still transactional? Or I should add there @Transactional? Answer What you are actually asking : is the @Transactional annotation on the method inherited. Short answer : no. Annotations on methods are never inherited. Long answer :

Advertisement