In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces mybatis how to achieve configuration file initialization, the article introduces in great detail, has a certain reference value, interested friends must read it!
If you look for any example, you can see that you can set up SqlSessionFactory by reading the configuration file, and then get the key sqlsession in build. This is the next example I randomly looked up from the Internet.
The key method is new SqlSessionFactoryBuilder (). Build (reader)
You can see that the result returned by parser.parse () is Configuration, and all the configuration files of mybatis are initialized in this class, which is the key class.
Here you can see the read configuration node. We know that the configuration node contains the configuration of the data source and the package or path of the xml file.
Here is the initialization mappers file
Get the resource path for parsing
Are you familiar with parsing xml files from here?
Read out the insert, select, update, delete nodes.
You should know when you see this.
Map map = new HashMap (); map.put ("trim", new TrimHandler ()); map.put ("where", new WhereHandler ()); map.put ("set", new SetHandler ()); map.put ("foreach", new ForEachHandler ()); map.put ("if", new IfHandler ()); map.put ("choose", new ChooseHandler ()); map.put ("when", new IfHandler ()); map.put ("otherwise", new OtherwiseHandler ()) Map.put ("bind", new BindHandler ())
Different tags implement different classes to assemble sql.
Finally, the initialized configuration data is put into MappedStatement.
Here comes the last big show.
Look at putting the successfully assigned MappedStatement back into the configuration.
These are all the contents of the article "how to initialize configuration files in mybatis". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.