spring-boot 2.x 集成mybatis 解决 org.apache.ibatis.binding.BindingException

spring-boot 2.x 集成mybatis 解决 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 问题

1.配置文件properties,配置映射 model和xml

#model路径

mybatis.type-aliases-package=com.jx.ekoochak.common.model

#xml映射路径注意是 “/” 方式不是 “.”

mybatis.mapper-locations=com/jx/ekoochak/common/**/*.xml

2.配置启动注入mapper接口类

import org.mybatis.spring.annotation.MapperScan;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.context.annotation.ComponentScan;



@SpringBootApplication

@ComponentScan("com.jx.ekoochak")

@MapperScan("com.jx.ekoochak.common.mapper")

public class EkoochakMerchantApplication {

public static void main(String[] args) {

SpringApplication.run(EkoochakMerchantApplication.class, args);

}

}

@MapperScan会去查找对应的mapper接口

3.pom.xml文件中添加如下:

如果你的mapper放在子项目中,则下面内容放到你的子项目pom中









src/main/java



**/*.xml











src/main/resources





 

你可能感兴趣的:(错误更改)