之前项目是使用的neo4j图数据,现在换成nebula想使用NgBatis框架,但是NgBatis框架与Mybatis 框架一起使用时会导致mapper交叉扫描,能否给个实际的ngBatis与mybatis项目集成的案例。网上这方面资料太少了,豆包问的一会一个样,太坑了。
可以看看这一篇哈
这个文章看了 在配置文件上指定了,而且NgBatis的Mapper.xml与MyBatis的Mapper.xml位置也完全隔离了,但是会导致我公共应用中的bean注入失败。然后ai又说啥要配置多数据源,启动类里要MyBatis和NgBatis的Mapper.xml与Mapper不能自动扫描啥的,都试了没有达到预期效果。每次启动都失败。现在卡在了我公共应用里的bean注入失败,导致程序启动不了。换成nebula-java又没问题
方便看下报错日志吗
稍等,我再重新搭建下理论上只需要按照ngbatis-demo项目的配置再加上上面那个文章里的配置应该就可以了吧?
是的,按 demo 的数据源配置就行。
还有这个注解跟 demo 不太一样,也是跟数据源相关
提示下面错误 JwtProperties是我公共应用中的 后面几个图是我的Application和yml文件以及公共应用的项目结构,和当前项目的结构,是我Application的配置有啥不对吗,还是说和ngbatis的有啥冲突吗?
start error:Error creating bean with name ‘org.springframework.scheduling.annotation.ProxyAsyncConfiguration’: Unsatisfied dependency expressed through method ‘setConfigurers’ parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘shiroFilter’ defined in class path resource [com/dp/dpmon/common/config/ShiroConfig.class]: Unsatisfied dependency expressed through method ‘shiroFilterFactoryBean’ parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘securityManager’ defined in class path resource [com/dp/dpmon/common/config/ShiroConfig.class]: Unsatisfied dependency expressed through method ‘securityManager’ parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘loginRedisServiceImpl’: Unsatisfied dependency expressed through field ‘jwtProperties’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘jwtProperties’ defined in file [D:\workspace\dpmoncloud\dpmon-common-saas\target\classes\com\dp\dpmon\shiro\JwtProperties.class]: Unexpected exception during bean creation; nested exception is java.lang.NullPointerException


大致看了下配置,扫描的范围并没有看出来冲突的地方。
可能需要重点关注下这后面的 Cause by,以及定位是哪个对象空了才比较好判断问题的根源出在哪
可能是我这边程序加载的问题吧,把那个方法改为返回一个固定值就能正常启动,但是相同的代码用nebula-java也能正常启动。所以不知道是不是ngbatis的加载bean或者啥的
NgBatis的bean加载机制有啥限制吗?
SysSetUtil
引入了什么 ngbatis 及衍生的 bean 吗
感觉感觉上有些奇怪,但是又想不出来问题会出在哪
我能怎么操作让NgBatis框架最后加载吗?
看了下 貌似ApplicationContext还未加载完成,加了sleep等待5s但看的ApplicationContext一直是null
看的NgBatis源码里 ConfigurableApplicationContext集成了ApplicationContext 这里会有影响吗?
我也不是很懂为什么这边的 applicationContext 会是空的。
没事了,感谢大佬支持,我们项目里有个地方通过静态工具类获取系统配置时要加载指定bean,这时候可能导致ApplicationContext未初始化就被访问,但是其他时候都没有这个问题。我现在先把那块逻辑改了下就好了。感谢大佬的支持。
客气哈~