Can spring annotations perceive each other ?, Spring annotation awareness

Source: Internet
Author: User

Can spring annotations perceive each other ?, Spring annotation awareness

Currently, spring mvc is used to write a remote control tool. Today I wrote two classes of dao layer, and then extracted a dao layer interface. When exporting the interface, the annotation @ Transactional of the original class is also exported to the interface. If annotations can be added to interfaces, they do not need to be added to implementation classes one by one.

In order to verify the reliability of the method, the system immediately started a trial. After removing the annotation of the first implementation class (Class1), the test can run normally. However, after the annotation of the second implementation class (Class2) is removed, it will not work. Otherwise, if you remove the Class2 annotation and retain the Class1 annotation, the test can also run. However, if neither of them has an annotation, and only the interface has an annotation, it cannot be run. Can these two implementation classes perceive each other?


This time, I removed the Class1 annotation and removed the interface annotation, and the test results failed. It confirms the conjecture that the interface and its implementation classes can be referenced by each other in case of an internal exception. This shows that the spring framework is robust and worth learning. Unfortunately, I have not read the source code of spring ..


Appendix:

For details about the project, see github.com/acearth/EventManage.git.

The problem code is located in the siat. pem. dao package.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.