当前位置:网站首页>Resolve the error: org.apache.ibatis.binding.bindingexception
Resolve the error: org.apache.ibatis.binding.bindingexception
2022-07-25 02:51:00 【young_ man2】
Project scenario :
I'm learning mybatis This problem occurred during the agent development of
Problem description
I'm learning today mybatis There was a mistake :
Exception in thread "main" org.apache.ibatis.binding.BindingException: Type interface com.wxy.dao.UserMapper is not known to the MapperRegistry.
at org.apache.ibatis.binding.MapperRegistry.getMapper(MapperRegistry.java:47)
at org.apache.ibatis.session.Configuration.getMapper(Configuration.java:745)
at org.apache.ibatis.session.defaults.DefaultSqlSession.getMapper(DefaultSqlSession.java:292)
at com.wxy.service.ServiceDemo.main(ServiceDemo.java:31)Cause analysis :
1. We need to know that this sentence means Yours Mapper Interface , By Spring After injection , But it can't be used normally mapper.xml Of sql;
2. there Spring After injection, it means , Your interface has been successfully scanned , But when Spring Try injecting a proxy (MyBatista Realization ) After the implementation class of , But it doesn't work . There are several possible situations here ;
① The interface has been scanned , But the proxy object was not found , Even if you try to inject , Also inject a wrong object ( It could be null)
② The interface has been scanned , Proxy object found , Also injected into the interface , But when calling a specific method , But I can't use ( Maybe other methods are normal )
Solution :
How to solve ?
1. Check your mapping file for namespace Is it consistent with the path of the interface file
For example, the fully qualified name of your interface is com.dao, Class called UserDao, Then in your mapping file namespace The parameter of should be com.dao.UserDao
【 Be careful : The path to direct replication is com/dao/UserDao.java This is not allowed , Only use . Connect 】
2. Check your mapping file for id Is it consistent with the method name in the interface ?
For example, your method is named findAll(), Then in your mapping file id It needs to be findAll
3. Check whether the output of your interface is consistent with yours resultType Agreement ?
Such as your resultType yes user class , Then the output of your interface 【 Suppose the method in your interface is List<xxx> findAll() ;】 That is, here you are xxx Need to be User
Pay attention , I'm going to use User Because I have renamed it in the core configuration file , So if you didn't rename , Yours resultType It needs to be the package name +User, Then your output inside xxx Still User Can , It won't make any difference
Give me a screenshot
① There is no core profile custom alias


② Customize the alias


4. Check the input of your interface and your paramType Is it consistent ?
【 Suppose the method in your interface is List<User> findAll(xxx) ;】, The mapping file is paramType="int", So you have xxx Need to be int i【 This parameter is arbitrary , As long as the parameter type is int Just go 】
I hope it helps you !
I wish you a job soon ! Come on together !
边栏推荐
- Introduction to web security telent testing and defense
- Three ways to solve your performance management problems
- HAC cluster is modified to stand-alone
- QT realizes calendar beautification
- "Introduction to interface testing" punch in to learn day05: how can a testing framework support restful interfaces?
- SQL recursive follow-up
- On Calc optimization of calcite
- Use unicloud cloud function to decode wechat motion steps in applet
- Flutter apple native Pinyin keyboard input exception on textfield | Pinyin input process callback problem
- SQL Server 2022 installation
猜你喜欢

Sequence diagram of UML diagram series

JS written test question -- promise, setTimeout, task queue comprehensive question

C: wechat chat software instance (wpf+websocket+webapi+entityframework)

Digital commerce cloud fine chemical industry management platform integrated informatization solution

【C】 Advanced knowledge of file operation

Unity refers to a variable in another class (its own instance)

New key points of ES6

JS foundation -- hijacking of this keyword

UDP message structure and precautions

IO (1) -io layering
随机推荐
Pagoda workman WSS reverse proxy socket legal domain name applet chat remove port
Wechat sports field reservation of the finished works of the applet graduation project (6) opening defense ppt
Explanation of C language file operation function
Common Oracle commands
Js a simple way to store several objects in an array
After six years of precipitation, new consumption has found a digital transformation paradigm
Daily three questions 7.15
SQL recursive follow-up
Clothing ERP | ten advantages of clothing ERP for enterprises
Keepalivetime=0 description of ThreadPoolExecutor
Tp5.1 login configuration method of whether to login public functions (complete login case)
Sequence diagram of UML diagram series
JS foundation -- math
Work arrangement of generator set
[circular array] JS method collection of circular array
The file in scanpy1.9.1 cannot be read in scanpy1.7.2. The problem is solved
Hyperchain hyperblockchain Shi Xingguo was interviewed by 36 krypton: the amount of customer cooperation consulting is doubling
Interview question -- event cycle
"Introduction to interface testing" punch in to learn day05: how can a testing framework support restful interfaces?
Tp5.1 paging (with parameter transfer)