nebula-contrib / ngbatis

NGBATIS is a database ORM framework base NebulaGraph + spring-boot, which takes advantage of the mybatis’ fashion development, including some de-factor operations in single table and vertex-edge, like mybatis-plus. NGBATIS 是一款针对 NebulaGraph + Springboot 的数据库 ORM 框架。借鉴于 MyBatis 的使用习惯进行开发。https://graph-cn.github.io/ngbatis-docs/
https://nebula-contrib.github.io/ngbatis/
Apache License 2.0
132 stars 42 forks source link

PersonDao Mappper Proxy #233

Open AhYi8 opened 1 year ago

AhYi8 commented 1 year ago

新项目启动报这个异常:

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 commented 1 year ago

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

AhYi8 commented 1 year ago

这是Mapper.xml 文件 图片

CorvusYe commented 1 year ago

新项目启动报这个异常:

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 完成的,加了这个注解会形成二次代理,从而导致报错

Childe-Mu commented 1 month ago

按照上述方式修改,还是报错,追踪下来,看到是这个 image bean没有被构建,还有其他需要修改的吗?