2
@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class,args);
    }
} 
59:37.637 [main] WARN  t.m.s.mapper.ClassPathMapperScanner - No MyBatis mapper was found in '[com.test.user]' package. Please check your configuration.
59:37.785 [main] WARN  o.m.s.mapper.ClassPathMapperScanner - No MyBatis mapper was found in '[com.test.user]' package. Please check your configuration.

I try to add @MapperScan(basePackages = {"com.test.user.mapper"}) of the Spring Boot Application it was :

....
import tk.mybatis.spring.annotation.MapperScan;

@SpringBootApplication
@MapperScan(basePackages = {"com.test.user.mapper"})
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class,args);
    }
} 

it take some warn like :

54:57.153 [main] WARN  o.m.s.mapper.ClassPathMapperScanner - No MyBatis mapper was found in '[com.test.user]' package. Please check your configuration.

then I change the package

org.mybatis.spring.annotation.MapperScan;
....
import org.mybatis.spring.annotation.MapperScan;

@SpringBootApplication
@MapperScan(basePackages = {"com.test.user.mapper"})
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class,args);
    }
} 

it take another warn :

59:22.290 [main] WARN  t.m.s.mapper.ClassPathMapperScanner - No MyBatis mapper was found in '[com.test.user]' package. Please check your configuration

this is part of dependencies

<!--mybatis-->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.3.1</version>
        </dependency>

        <!--mapper-->
        <dependency>
            <groupId>tk.mybatis</groupId>
            <artifactId>mapper-spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.mybatis</groupId>
                    <artifactId>mybatis-spring</artifactId>
                </exclusion>
            </exclusions>
<!--            <version>1.2.4</version>-->
        </dependency>

Maybe it's a warn, but I want get's the WHY and Details?

monlen
  • 21
  • 1

1 Answers1

0

According to the docs, @MapperScan is used to scan the MyBatis mapper interfaces.

If you got the warning log, I believe the Mybatis mappers you would want to work with is not detected by Spring.

For XML mappers, make sure the mapper namespace is correct.

mapper namespace="com.test.user.mapper.SomeMybatisXMLMapper

For Java interface mappers, make sure the java file class name match with your package.

com.test.user.mapper.SomeMybatisJavaInterfaceMapper