In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to use @MapperScan annotation and @Mapper annotation". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian slowly and deeply to study and learn "how to use @MapperScan annotation and @Mapper annotation" together!
directory
@MapperScan annotation and @Mapper annotation usage
Difference between MapperScan annotation and @Mapper
@MapperScan annotation and @Mapper annotation usage
@Mapper generally corresponds to an interface, which is equivalent to a Mapper.xml file. Its role is to generate a dynamic proxy class from the interface.
When we write a lot of mapper interfaces, we don't have to spend too much time writing them one by one, which is too much trouble. We can use the @ManpperScan annotation to indicate the package to scan, which can scan all mapper files.
How it is done, we can check the source code inside, the main role is the @Import annotation inside. Interested parties can continue to check the source code of MapperScannerRgiatrar, mainly look at registerBeanDefinitions, you will suddenly see.
Difference between MapperScan annotation and @Mapper
As follows:
At first, we added @Mapper to the mapper interface, and automatically injected beans through the namespace namespace under the xml file. This method requires that each mapper class needs to add this annotation, which is more troublesome;
We can add @MapperScan("Path of Mapper package") annotation to the startup class to scan the mapper package, so that the interface in the mapper layer can not use @Mapper annotation;
Also, annotate multiple packages with @MapperScan.
Thank you for reading, the above is "how to use @MapperScan annotation and @Mapper annotation" content, after the study of this article, I believe you have a deeper understanding of how to use @MapperScan annotation and @Mapper annotation, the specific use needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.