![]() This bean post-processor adds an advisor to any bean that’s annotated with so that any platform-specific exceptions are caught and then rethrown as one of Spring’s unchecked data access exceptions. Though for that you also need to declare .PersistenceExceptionTranslationPostProcessor as Spring bean in your application context. First, they are treated as Spring bean, and second, you can put special behavior required by that layer.įor example, not only helping in annotation based configure but also catch Platform-specific exceptions and re-throw them as one of Spring’s unified unchecked exception. A Spring bean in the service layer should be annotated using instead of annotation and a spring bean in the persistence layer should be annotated with annotation.īy using a specialized annotation we hit two birds with one stone. The same is true for and annotation, they are a specialization of in service and persistence layer. ![]() This latter property is used by web-specific tools and functionalities. Instead of using on a controller class in Spring MVC, we use, which is more readable and appropriate.īy using that annotation we do two things, first, we declare that this class is a Spring bean and should be created and maintained by Spring ApplicationContext, but also we indicate that its a controller in MVC setup. They are nothing but the specialized form of annotation for certain situations. Now that you know what does annotation does let's see what does and annotation do. This functionality was enabled and disabled using tag. This means you don't declare that bean using the tag and inject the dependency, it will be done automatically by Spring. From Spring 2.5 annotation-based dependency injection was introduced, which automatically scans and registers classes as Spring bean which is annotated using annotation. In later versions, they provide annotation-based dependency injection and Java-based configuration. For a large project, this quickly becomes a massive task, and Spring guys recognize the problem rather quickly. During the initial release of Spring, all beans are used to be declared in an XML file. ![]() Before you learn the difference between and annotations in the Spring framework, it's important to understand the role of annotation in Spring. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |