The mapper interface file automatically generated by spring boot cannot be injected, @ MapperScan annotation has been added

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
        PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">

<generatorConfiguration>
    <properties resource="application.properties"/>

    <context id="Mysql" targetRuntime="MyBatis3Simple" defaultModelType="flat">
                <property name="beginningDelimiter" value="`"/>
        <property name="endingDelimiter" value="`"/>

        <!-- Mapper -->
        <plugin type="tk.mybatis.mapper.generator.MapperPlugin">
            <property name="mappers" value="com.mall.demo.util.MyMapper"/>
        </plugin>

        <jdbcConnection driverClass="${spring.datasource.driver-class-name}"
                        connectionURL="${spring.datasource.url}"
                        userId="${spring.datasource.username}"
                        password="${spring.datasource.password}">
        </jdbcConnection>

        <javaModelGenerator targetPackage="com.mall.demo.model" targetProject="src/main/java" >
            <property name="enableSubPackages" value="true" />
        </javaModelGenerator>

        <sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
            <property name="enableSubPackages" value="true" />
        </sqlMapGenerator>

        <javaClientGenerator targetPackage="com.mall.demo.mapper" targetProject="src/main/java" type="XMLMAPPER">
            <property name="enableSubPackages" value="true" />
        </javaClientGenerator>

        <table tableName="category">
            <!--mysql -->
            <!--<generatedKey column="id" sqlStatement="Mysql" identity="true"/>-->
            <!--oracle -->
            <!--<generatedKey column="id" sqlStatement="select SEQ_{1}.nextval from dual" identity="false" type="pre"/>-->
        </table>
    </context>
</generatorConfiguration>

spring boot :

package com.mall.demo;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan(basePackages = "com.mall.demo.mapper")
public class MallProjectApplication {

    public static void main(String[] args) {
        SpringApplication.run(MallProjectApplication.class, args);
    }
}

uses an editor that uses Autowired injection in the IDEA, service implementation class, but the run still indicates that the injection was not successful.
error message is as follows:

Description:

Field categoryMapper in com.mall.demo.service.impl.CategoryServiceImpl required a bean of type "com.mall.demo.mapper.CategoryMapper" that could not be found.


Action:

Consider defining a bean of type "com.mall.demo.mapper.CategoryMapper" in your configuration.
Mar.07,2021

this problem is usually due to the fact that the @ Mapper annotation is not added to the interface. The landlord checks whether the class under the "com.mall.demo.util.MyMapper" package has the following comments

.

clipboard.png


Thank you very much. Problem solved. The
problem is that idea did not introduce a package in the local repository (the local warehouse has a tk.mybatis.mapper package).
solution: reinstall a new local repository with maven,idea configuration. Just download the jar package again.

as to why idea cannot follow the jar package of the new local warehouse, the reason has not been checked. (after deleting the jar package, auto import was not downloaded locally, and pom did not report an error)


Ah, I also encountered the same problem, which is exactly the same as yours, but I don't want to reinstall the basement

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bdc03c-312e6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bdc03c-312e6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?