问题:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-03-03 17:13:02.341 ERROR 17004 --- [restartedMain] o.s.boot.SpringApplication : Application run failedorg.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userMapper' defined in file [E:\Alun\springboot_demo\target\classes\com\example\demo\mapper\UserMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.lang.NoClassDefFoundError: org/mybatis/logging/LoggerFactory
方法1:
肯定有人跟我第一眼看到了这个
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userMapper' defined in file
所以最简单的方法就是在这个地方加上注解@Mapper
方法2:如果方法1还没解决再看看pom.xml中的这个配置:
当我们创建一个SpringBoot项目,它pom.xml中的这个地方不是注释的,此时该把他注释掉,然后删除target,再点击import changes,等待编译再运行就正常了。