Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PersonDao Mappper Proxy #233

Open
AhYi8 opened this issue Sep 23, 2023 · 3 comments
Open

PersonDao Mappper Proxy #233

AhYi8 opened this issue Sep 23, 2023 · 3 comments

Comments

@AhYi8
Copy link

AhYi8 commented Sep 23, 2023

新项目启动报这个异常:

java.lang.NullPointerException: null
	at org.nebula.contrib.ngbatis.proxy.MapperProxy.invoke(MapperProxy.java:73) ~[ngbatis-1.1.3.jar:1.1.3]
	at com.ayi.ngbatis.dao.PersonDao$Proxy.select1(Unknown Source) ~[na:na]
	at com.ayi.ngbatis.service.impl.PersonServiceImpl.select1(PersonServiceImpl.java:79) ~[classes/:na]
	at com.ayi.ngbatis.controller.PersonController.select1(PersonController.java:18) ~[classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_321]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_321]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_321]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_321]
	......

启动类

图片

项目结构

图片

Dao 类

图片

ServiceImp 类

图片

@AhYi8
Copy link
Author

AhYi8 commented Sep 23, 2023

哪位大佬知道为啥,刚学,踩的坑太多了

@AhYi8
Copy link
Author

AhYi8 commented Sep 23, 2023

这是Mapper.xml 文件
图片

@CorvusYe
Copy link
Collaborator

新项目启动报这个异常:

java.lang.NullPointerException: null
	at org.nebula.contrib.ngbatis.proxy.MapperProxy.invoke(MapperProxy.java:73) ~[ngbatis-1.1.3.jar:1.1.3]
	at com.ayi.ngbatis.dao.PersonDao$Proxy.select1(Unknown Source) ~[na:na]
	at com.ayi.ngbatis.service.impl.PersonServiceImpl.select1(PersonServiceImpl.java:79) ~[classes/:na]
	at com.ayi.ngbatis.controller.PersonController.select1(PersonController.java:18) ~[classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_321]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_321]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_321]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_321]
	......

启动类

图片

这里的报空是因为基本包的内置组件没有扫描到,可以改成 scanBasePackages = { "org.nebula.contrib.ngbatis", "com.ayi.ngbatis" }

Dao 类

图片

这里的@Component可以不需要,直接去掉就可以,扫描的发现是通过 xml 的 namespace 完成的,加了这个注解会形成二次代理,从而导致报错

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants