spring boot+mybatis install时的报错-:

时间:2024-11-10 18:46:58

2018-12-16 13:10:53.295  INFO 12868 --- [           main]     : No active profile set, falling back to default profiles: default
2018-12-16 13:10:53.327  INFO 12868 --- [           main]   : Refreshing @5f9edf14: startup date [Sun Dec 16 13:10:53 CST 2018]; root of context hierarchy
2018-12-16 13:10:54.861  WARN 12868 --- [           main]   : Exception encountered during context initialization - cancelling refresh attempt: : Error creating bean with name 'helloSpringBootApplication': Unsatisfied dependency expressed through field 'userService'; nested exception is : Error creating bean with name 'userServiceImpl': Injection of resource dependencies failed; nested exception is : Error creating bean with name 'userMapper' defined in file [D:\worksapceforidea\springbootdemo\target\classes\com\example\springbootdemo\dao\]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is : Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/]: Bean instantiation via factory method failed; nested exception is : Failed to instantiate []: Factory method 'sqlSessionFactory' threw exception; nested exception is : (Ljava/lang/Class;)V
2018-12-16 13:10:54.868  INFO 12868 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-12-16 13:10:54.876 ERROR 12868 --- [           main]               : Application run failed

: Error creating bean with name 'helloSpringBootApplication': Unsatisfied dependency expressed through field 'userService'; nested exception is : Error creating bean with name 'userServiceImpl': Injection of resource dependencies failed; nested exception is : Error creating bean with name 'userMapper' defined in file [D:\worksapceforidea\springbootdemo\target\classes\com\example\springbootdemo\dao\]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is : Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/]: Bean instantiation via factory method failed; nested exception is : Failed to instantiate []: Factory method 'sqlSessionFactory' threw exception; nested exception is : (Ljava/lang/Class;)V
    at $(:586) ~[spring-beans-5.0.:5.0.]
    at (:91) ~[spring-beans-5.0.:5.0.]
    at (:372) ~[spring-beans-5.0.:5.0.]
    at (:1341) ~[spring-beans-5.0.:5.0.]
    at (:572) ~[spring-beans-5.0.:5.0.]
    at (:495) ~[spring-beans-5.0.:5.0.]
    at $doGetBean$0(:317) ~[spring-beans-5.0.:5.0.]
    at $$Lambda$116/(Unknown Source) ~[na:na]
    at (:222) ~[spring-beans-5.0.:5.0.]
    at (:315) ~[spring-beans-5.0.:5.0.]
    at (:199) ~[spring-beans-5.0.:5.0.]
    at (:759) ~[spring-beans-5.0.:5.0.]
    at (:869) ~[spring-context-5.0.:5.0.]
    at (:550) ~[spring-context-5.0.:5.0.]
    at (:762) ~[spring-boot-2.0.:2.0.]
    at (:398) ~[spring-boot-2.0.:2.0.]
    at (:330) ~[spring-boot-2.0.:2.0.]
    at (:139) [spring-boot-test-2.0.:2.0.]
    at (:99) [spring-test-5.0.:5.0.]
    at (:117) [spring-test-5.0.:5.0.]
    at (:108) [spring-test-5.0.:5.0.]
    at (:190) [spring-test-5.0.:5.0.]
    at (:132) [spring-test-5.0.:5.0.]
    at (:246) [spring-test-5.0.:5.0.]
    at .junit4.(:227) [spring-test-5.0.:5.0.]
    at .junit4.SpringJUnit4ClassRunner$(:289) [spring-test-5.0.:5.0.]
    at (:12) [junit-4.:4.12]
    at .junit4.(:291) [spring-test-5.0.:5.0.]
    at .junit4.(:246) [spring-test-5.0.:5.0.]
    at .junit4.(:97) [spring-test-5.0.:5.0.]
    at $(:290) [junit-4.:4.12]
    at $(:71) [junit-4.:4.12]
    at (:288) [junit-4.:4.12]
    at $000(:58) [junit-4.:4.12]
    at $(:268) [junit-4.:4.12]
    at

 

折腾了十几分钟,发现为没有加@Mapper注解(dao层),且之前自己编写mybatis的sessionFactory的时候加入了一个3.2版本的mybatis依赖包,导致@Mapper注解无法识别(版本太低),记录一下,方便学习。

相关文章