程序员王小瑞 2023-03-02 15:34 采纳率: 19.2%
浏览 20

springCloud数据源为空问题

线下一直报这个错误,不知道为什么,在网上搜看教程说jdbc加时区设置,我也加了,但是还是这样。

Unexpected error occurred invoking async method 'public void com.hyzk.business.web.bom.service.impl.AsyncServiceWork.createQcEqument(java.lang.Integer,com.hyzk.business.common.bean.vo.QRCodeVO)'.
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection: Cannot determine target DataSource for lookup key [null]
### The error may exist in file [D:\workspace\GitLab\tongfei\mini-mes\target\classes\mybatis\web\bom\CpPartMapper.xml]
### The error may involve com.hyzk.business.web.bom.dao.PartMapper.insertQrCode
### The error occurred while executing an update
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection: Cannot determine target DataSource for lookup key [null]
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
    at com.sun.proxy.$Proxy128.insert(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:278)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)
    at com.sun.proxy.$Proxy200.insertQrCode(Unknown Source)
    at com.hyzk.business.web.bom.service.impl.AsyncServiceWork.createQcEqument(AsyncServiceWork.java:28)
    at com.hyzk.business.web.bom.service.impl.AsyncServiceWork$$FastClassBySpringCGLIB$$df235708.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:746)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection: Cannot determine target DataSource for lookup key [null]
### The error may exist in file [D:\workspace\GitLab\tongfei\mini-mes\target\classes\mybatis\web\bom\CpPartMapper.xml]
### The error may involve com.hyzk.business.web.bom.dao.PartMapper.insertQrCode
### The error occurred while executing an update
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection: Cannot determine target DataSource for lookup key [null]
    at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:199)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:184)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433)
    ... 15 common frames omitted
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection: Cannot determine target DataSource for lookup key [null]
 

jdbc连接 :

img


具体报错在这里:

img

在这个地方报错。
断点看了,这个执行完之后插入成功了,但是放行之后就会报上面的错。

  • 写回答

3条回答 默认 最新

  • Tomshidi 2023-03-02 15:47
    关注

    把dataBaseDo对象的值都打印出来看看,看看getDataName方法是不是返回了null。

    评论

报告相同问题?

问题事件

  • 创建了问题 3月2日

悬赏问题

  • ¥30 不会,学习,有偿解答
  • ¥15 SQL查询语句报错(检查)
  • ¥15 此表中公式应该怎么写
  • ¥15 求HI-TECH PICC 9.50 PL3安装包
  • ¥15 下载ctorch报错,求解
  • ¥15 如何入门学习c语言,单片机
  • ¥15 idea 编辑语言的选择
  • ¥15 Windows下部署Asmjit
  • ¥15 请问双层规划模型的上下层目标函数不一致,是如何保证迭代收敛性的
  • ¥30 微信小程序 前端页面内容搜索