1.报错信息
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘scheduledTaskMapper’ defined in URL [jar:file:/D:/gongzuo/shikong/java/ckedi/target/ckedi-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/com/shikong/ckedi/mapper/ScheduledTaskMapper.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 [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method ‘dataSource’ threw exception; nested exception is java.lang.IllegalStateException: Cannot load driver class: com.microsoft.sqlserver.jdbc.SQLServerDriver
2.问题描述
idea启动完全没没有问题打包执行就报错
3.解决方案
pom文件里没有相应的数据库驱动以上报错java.lang.IllegalStateException: Cannot load driver class: com.microsoft.sqlserver.jdbc.SQLServerDriver
可以看出没有SQLServer的数据库驱动添加即可
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>9.2.1.jre8</version>
</dependency>