非mabytis接口被ibatis代理并提示Invalid bound statement

非Mabytis接口,在实际运行过程中被 ibatis proxy 并提示Invalid bound statement (not found) 

具体的接口调用如下:

public interface LoginServer<T extends User> {}

@Service
public class DefaultLoginServer implements LoginServer {}


@Component
public class DefaultCoreRealmServer extends AuthorizingRealm {
    @Autowired
    private LoginServer loginServer;
 /..../
 @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException {
 /..../
        loginServer.login(token.getUsername());
 /..../
}
        
 /..../
        
}

启动类如下

// cn.xxxx.xxx.core 为项目根包名
@SpringBootApplication(scanBasePackages = {"cn.xxxx.xxx.core"})
@ComponentScan({"cn.xxxx.xxx.core"})
@MapperScan({"cn.xxxx.xxx.core"})
public class CoreApplication {
    public static void main(String[] args) {
        SpringApplication.run(CoreApplication.class, args);
    }
}

需要说明的时候,如果注释掉 @MapperScan({"cn.xxxx.xxx.core"})  将不会出现此问题,目前core模块中并没有实际使用mabytis,但后续会扩展相关接口和类,因此不可能 一直 注释掉 @MapperScan({"cn.xxxx.xxx.core"}) 

 

在实际运行过程中,若注释掉 @MapperScan({"cn.xxxx.xxx.core"})  debug显示对象为 实际的实现类@id ,若不注释掉会显示为

ibatis.*.*proxy@id 因此可以肯定当前接口被其进行了代理,但是代码中并没有声明? 

mybatis

@MapperScan({"XX"}) 中XX 范围过大,导致其他即可被Mybatis代理,应该设置为仅扫描 Mapper 接口如下

@MapperScan({"cn.lpc.**.mapper"}) 扫描 lpc 下 所有 mapper 的包

@MapperScan({"XX"}) 中XX 范围过大,导致其他即可被Mybatis代理,应该设置为仅扫描 Mapper 接口如下

@MapperScan({"cn.lpc.**.mapper"}) 扫描 lpc 下 所有 mapper 的包