In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "mybatis has been loading xml how to solve", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "mybatis has been loading xml how to solve" it!
Mybatis keeps loading xml and finds an error
When we write the springmvc+mybatis project, when we start the project, the mapper configuration file is always brushed and loaded.
For our great programmers, this is not terrible, the terrible thing is that there are no mistakes to print out. I have no idea how to do it.
Today, we finally found a solution.
Find the org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory class and use the following method:
Protected void autowireByType (String beanName, AbstractBeanDefinition mbd, BeanWrapper bw, MutablePropertyValues pvs) {catch (BeansException ex) {throw new UnsatisfiedDependencyException (mbd.getResourceDescription (), beanName, propertyName, ex);}
You can do it at the breakpoint of the throw line, which is the first place to catch exceptions. When there is an error in the Mapper.xml file, the exception information will be output.
There is another question: why can you only see an infinite line of logs after an error, but not the specific exception information here?
By tracing the code, you find the methods in the org.springframework.beans.factory.support.AbstractBeanFactory class:
Protected Class getTypeForFactoryBean (String beanName, RootBeanDefinition mbd) {if (! mbd.isSingleton ()) {return null;} try {FactoryBean factoryBean = doGetBean (FACTORY_BEAN_PREFIX + beanName, FactoryBean.class, null, true); return getTypeForFactoryBean (factoryBean);} catch (BeanCreationException ex) {/ / Can only happen when getting a FactoryBean. If (logger.isDebugEnabled ()) {logger.debug ("Ignoring bean creation exception on FactoryBean type check:" + ex);} onSuppressedException (ex); return null;}}
After the exception is caught here, the direct return null causes the exception to be swallowed.
Mybatis lazy loading (xml)
For one-to-one and many-to-one (mybatis maps to one-to-one). When querying, you can query together.
But for one-to-many and many-to-many. Maybe there is a lot of data corresponding to that much, and we don't need that much. Then querying together will waste performance resources.
So, mybatis has lazy loading.
Mysql loads immediately by default.
Lazy loading has a fetchType property in the Collection or association property, and eager loads immediately. Lazy loads lazily.
In the mybatis configuration file, thank you for reading, the above is "mybatis has been loading xml how to solve" the content, after the study of this article, I believe you have a deeper understanding of how mybatis has been loading xml to solve this problem, the specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.