mybatisplus中sqlSessionFactory或sqlSessionTemplate不自动注入

mybatisplus中sqlSessionFactory或sqlSessionTemplate不自动注入

报错复现:

Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required

问题分析:

出现此类情况的原因是mybatisPlus中没有注入sqlSessionFactorysqlSessionTemplate

解决方案:

检查pom依赖文件,查看mybatisPlus依赖是否使用的为mybatisplus-spring-boot-starter依赖,如果是的话请修改依赖为mybatis-plus-boot-starter

        <!-- mybatis plus依赖 -->
        <!-- 使用此条依赖会出现sqlSessionFactory或sqlSessionTemplate不自动注入的问题 -->
<!--        <dependency>-->
<!--            <groupId>com.baomidou</groupId>-->
<!--            <artifactId>mybatisplus-spring-boot-starter</artifactId>-->
<!--            <version>1.0.5</version>-->
<!--        </dependency>-->
        <!-- 使用以下依赖便能解决问题 -->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.5.1</version>
        </dependency>

猜你喜欢

转载自blog.csdn.net/xiri_/article/details/124923039