启动失败 Application run failed

来源:11-2 使用mybatis+SpringBoot完成第一个查询demo

慕九州9396466

2019-09-24

老师,我这边报错了,网上搜是需要什么@service
,我也看不懂,求解决啊

20:05:34.433 [main] WARN o.m.s.mapper.ClassPathMapperScanner - No MyBatis mapper was found in ‘[com.course.controller]’ package. Please check your configuration.
20:05:35.198 [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘demo’: Unsatisfied dependency expressed through field ‘template’; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘sqlSessionTemplate’ defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method ‘sqlSessionTemplate’ parameter 0; 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/DataSourceConfigurationHikari.class]:Beaninstantiationviafactorymethodfailed;nestedexceptionisorg.springframework.beans.BeanInstantiationException:Failedtoinstantiate[com.zaxxer.hikari.HikariDataSource]:Factorymethod′dataSource′threwexception;nestedexceptionisjava.lang.IllegalStateException:Cannotloaddriverclass:com.mysql.jdbc.driver20:05:35.199[main]WARNo.s.c.a.CommonAnnotationBeanPostProcessor−Destroymethodonbeanwithname′application′threwanexception:java.lang.NullPointerException20:05:35.226[main]ERRORo.s.boot.SpringApplication−Applicationrunfailedorg.springframework.beans.factory.UnsatisfiedDependencyException:Errorcreatingbeanwithname′demo′:Unsatisfieddependencyexpressedthroughfield′template′;nestedexceptionisorg.springframework.beans.factory.UnsatisfiedDependencyException:Errorcreatingbeanwithname′sqlSessionTemplate′definedinclasspathresource[org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]:Unsatisfieddependencyexpressedthroughmethod′sqlSessionTemplate′parameter0;nestedexceptionisorg.springframework.beans.factory.UnsatisfiedDependencyException:Errorcreatingbeanwithname′sqlSessionFactory′definedinclasspathresource[org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]:Unsatisfieddependencyexpressedthroughmethod′sqlSessionFactory′parameter0;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:Errorcreatingbeanwithname′dataSource′definedinclasspathresource[org/springframework/boot/autoconfigure/jdbc/DataSourceConfigurationHikari.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.mysql.jdbc.driver 20:05:35.199 [main] WARN o.s.c.a.CommonAnnotationBeanPostProcessor - Destroy method on bean with name 'application' threw an exception: java.lang.NullPointerException 20:05:35.226 [main] ERROR o.s.boot.SpringApplication - Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'demo': Unsatisfied dependency expressed through field 'template'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionTemplate' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionTemplate' parameter 0; 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/DataSourceConfigurationHikari.class]:Beaninstantiationviafactorymethodfailed;nestedexceptionisorg.springframework.beans.BeanInstantiationException:Failedtoinstantiate[com.zaxxer.hikari.HikariDataSource]:FactorymethoddataSourcethrewexception;nestedexceptionisjava.lang.IllegalStateException:Cannotloaddriverclass:com.mysql.jdbc.driver20:05:35.199[main]WARNo.s.c.a.CommonAnnotationBeanPostProcessorDestroymethodonbeanwithnameapplicationthrewanexception:java.lang.NullPointerException20:05:35.226[main]ERRORo.s.boot.SpringApplicationApplicationrunfailedorg.springframework.beans.factory.UnsatisfiedDependencyException:Errorcreatingbeanwithnamedemo:Unsatisfieddependencyexpressedthroughfieldtemplate;nestedexceptionisorg.springframework.beans.factory.UnsatisfiedDependencyException:ErrorcreatingbeanwithnamesqlSessionTemplatedefinedinclasspathresource[org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]:UnsatisfieddependencyexpressedthroughmethodsqlSessionTemplateparameter0;nestedexceptionisorg.springframework.beans.factory.UnsatisfiedDependencyException:ErrorcreatingbeanwithnamesqlSessionFactorydefinedinclasspathresource[org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]:UnsatisfieddependencyexpressedthroughmethodsqlSessionFactoryparameter0;nestedexceptionisorg.springframework.beans.factory.BeanCreationException:ErrorcreatingbeanwithnamedataSourcedefinedinclasspathresource[org/springframework/boot/autoconfigure/jdbc/DataSourceConfigurationHikari.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.mysql.jdbc.driver图片描述

写回答

1回答

大周

2019-10-04

 Error creating bean with name 'demo'   这一句后边是关键的信息。 还有Cannot load driver class: com.mysql.jdbc.driver   。  有这么几种可能。 1、下载包没有下载成功。 2、对应的mysql driver下载的版本和你mysql数据库的版本不对应。

0
0

Java接口自动化测试实战,搞定理论基础+典型应用场景

打破传统测试用例设计方法,搞懂基于TestNG的接口自动化测试技术

2086 学习 · 920 问题

查看课程