nested exception is java.sql.SQLException: ${sky.datasource.driver-class-name}

看见很多博主都在聊数据库字段错误,或者contorller层,service层,mapper层的注解忘加等错误,但根据我细致的检查后,又没有问题,所以,是哪里出了问题呢?

先来看错误信息:

Error creating bean with name 'employeeController': Unsatisfied dependency expressed through field 'employeeService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'employeeServiceImpl': Unsatisfied dependency expressed through field 'employeeMapper'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'employeeMapper' defined in file [D:\code\Springboot+Mybatis项目-个人\MYsky-take-out\sky-server\target\classes\com\sky\mapper\EmployeeMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [com/alibaba/druid/spring/boot/autoconfigure/DruidDataSourceAutoConfigure.class]: Invocation of init method failed; nested exception is java.sql.SQLException: ${sky.datasource.driver-class-name}

主要是最后一句话:${sky.datasource.driver-class-name}

根据我的配置文件:

使用的是这种方式,在另外一个配置文件里存的值,而显然是这种方式导致的连接问题。

所以解决方法就是,将这些值改成数据库连接的值。

具体为什么,我也不清楚,还希望有大佬能为我解答一下。

此外,我还尝试过将datasource代码块删去,留有另一个yml文件里的数据库连接信息

但idea会报错,显示找不到驱动程序

所以,我的可以解决问题,但不清楚具体什么原因导致的,此项目,在前一天晚上还可以正常运行,第二天运行就出现此问题了。

希望有大佬能为我解答一下。

  • 24
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值