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

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

先来看错误信息:

nested exception is java.sql.SQLException: ${sky.datasource.driver-class-name}_第1张图片

nested exception is java.sql.SQLException: ${sky.datasource.driver-class-name}_第2张图片

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}

根据我的配置文件:nested exception is java.sql.SQLException: ${sky.datasource.driver-class-name}_第3张图片

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

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

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

此外,我还尝试过将datasource代码块删去,留有另一个yml文件里的数据库连接信息nested exception is java.sql.SQLException: ${sky.datasource.driver-class-name}_第4张图片

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

nested exception is java.sql.SQLException: ${sky.datasource.driver-class-name}_第5张图片

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

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

你可能感兴趣的:(java,mybatis,开发语言)