org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

我这里的dao层引用了多个二级包名,调用的时候,出现了下面的问题:

13:42:40.553 ERROR o.a.c.c.C.[.[localhost].[/].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.dzmsoft.db.core.base.dao.PerpetualCalendarMapper.selectByExample] with root cause
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.dzmsoft.db.core.base.dao.PerpetualCalendarMapper.selectByExample
	at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:227)
	at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:49)
	at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:65)
	at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)
	at com.sun.proxy.$Proxy94.selectByExample(Unknown Source)
	at com.dzmsoft.db.core.base.service.impl.PerpetualCalendarServiceImpl.selectByExample(PerpetualCalendarServiceImpl.java:47)
	at com.dzmsoft.db.core.base.service.impl.PerpetualCalendarServiceImpl$$FastClassBySpringCGLIB$$ac053baa.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)

1 pom.xml中的配置
先确定mapper.xml已经打进去了,这个应该没有问题。有必要还是检查一下jar

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
        </resources>
    </build>

1

2 yml中的配置
这个问题应该就是dao中的PerpetualCalendarMappermapping中的PerpetualCalendarMapper.xml关系没有建立

mybatis:
  mapper-locations: classpath*:com/tt/**/mapping/*.xml,classpath*:com/dzmsoft/**/mapping/*.xml

3 @MapperScan
这个是针对注解方式的mybatis,我们系统中采用的是xml,这种情况不要也可以。
参考SpringBoot整合MyBatis

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;

@Slf4j
@SpringBootApplication
@ComponentScan(basePackages={"com.tt.*","com.dzmsoft.*"})
@MapperScan(basePackages={"com.tt.**.dao","com.dzmsoft.**.dao"})
@EnableDiscoveryClient
@EnableAsync
public class FayServerApplication {

    public static void main(String[] args) {
        try {
            SpringApplication.run(FayServerApplication.class, args);
        } finally {
            log.info("server start finish");
        }
    }
}

检查日志发现

14:16:12.755 WARN  org.mybatis.spring.mapper.ClassPathMapperScanner - No MyBatis mapper was found in '[com.tt.**.dao, com.dzmsoft.**.dao]' package. Please check your configuration.

问题在哪里呢?如果一个基础包是没有问题的,现在多个就有问题了,待解决中。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

warrah

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值