背景
大家好,最近在用gradle构建springboot +mybatis框架的同时,发现配置完文件后,在运行的时候,报了这样错误
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
我们现在把配置mybatis的过程列一下
配置myabtis
# mybatis configuration.
mybatis.mapper-locations: classpath:com/jjxt/b/maper/**/*Mapper.xml
mybatis.type-aliases-package: com.jjxt.b.entity
mybatis.check-config-location: true
mybatis.configuration.mapUnderscoreToCamelCase=true
mybatis jar包引入
dependencies {
implementation (
"org.springframework.boot:spring-boot-starter-web:${springBootVersion}",
"org.springframework.boot:spring-boot-starter-security:${springBootVersion}",
"org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.3",
"mysql:mysql-connector-java:5.1.46",
"com.github.pagehelper:pagehelper-spring-boot-starter:1.2.13",
'io.springfox:springfox-swagger2:2.8.0',
'io.springfox:springfox-swagger-ui:2.8.0',
"com.mchange:c3p0:0.9.5.2",
"jakarta.xml.bind:jakarta.xml.bind-api:2.3.2",
"org.glassfish.jaxb:jaxb-runtime:2.3.2",
'org.apache.commons:commons-lang3:3.10',
'org.apache.commons:commons-collections4:4.4',
// 'org.apache.commons:commons-text:1.8'
'org.apache.pdfbox:pdfbox:2.0.20',
'org.apache.pdfbox:jbig2-imageio:3.0.0',
'org.apache.pdfbox:pdfbox-tools:2.0.20',
'org.apache.poi:poi:4.1.2',
'org.apache.poi:poi-ooxml:4.1.2',
'com.itextpdf:itext7-core:7.1.11',
'com.ibm.icu:icu4j:67.1',
)
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testCompile (
'junit:junit:4.12',
"org.mockito:mockito-core:2.+"
)
testCompile ('org.springframework.boot:spring-boot-starter-test'){
exclude group: "com.vaadin.external.google", module:"android-json"
}
xml文件配置
这里一定注意,xml文件的文件路径,一定要跟上面mybatis路径配置一致
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jjxt.b.mapper.users.UserMapper">
<select id="getPhone" resultType="com.jjxt.b.entity.users.User">
select * from sys_users where phone=#{phone} and deleted = false
</select>
</mapper>
文件解决
出现以上问题 Invalid bound statement (not found) 如何解决呢
还是gradle对于xml文件编译的配置
打开build.gradle文件 添加下面的内容
processResources {
from('src/main/java') {
include '**/*.xml'
}
}
问题解决 希望可以帮到大家 大家也可可以关注微信公众号【泉城IT圈子】,更多精彩文章